From 6654fff377c32086421f2691327646915e403d20 Mon Sep 17 00:00:00 2001 From: Grissiom Date: Wed, 6 Oct 2010 20:58:13 +0800 Subject: [PATCH] fix null reference when erase TERM env Way to reproduce: > set -e TERM fish: function contains_internal called with null value for argument a. fish: This is a bug. If you can reproduce it, please send a bug report to fish-users@lists.sf.net. fish: Backtrace: /home/grissiom/sysroot/bin/fish(show_stackframe+0x1a) [0x43519a] /home/grissiom/sysroot/bin/fish(contains_internal+0xce) [0x4373ee] /home/grissiom/sysroot/bin/fish(reader_write_title+0x59) [0x424179] /home/grissiom/sysroot/bin/fish() [0x4242d5] /home/grissiom/sysroot/bin/fish(reader_readline+0x54) [0x425974] /home/grissiom/sysroot/bin/fish(reader_read+0xba) [0x42742a] /home/grissiom/sysroot/bin/fish(main+0x4be) [0x43b19e] /lib64/libc.so.6(__libc_start_main+0xfd) [0x7fcbe0dcbb6d] /home/grissiom/sysroot/bin/fish() [0x408c29] --- reader.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/reader.c b/reader.c index 4af23fa6d..db4c1c9cc 100644 --- a/reader.c +++ b/reader.c @@ -624,10 +624,16 @@ void reader_write_title() don't. Since we can't see the underlying terminal below screen there is no way to fix this. */ - if( !term || !contains( term, L"xterm", L"screen", L"nxterm", L"rxvt" ) ) + if ( !term ) + { + return; + } + + if( !contains( term, L"xterm", L"screen", L"nxterm", L"rxvt" ) ) { char *n = ttyname( STDIN_FILENO ); + if( contains( term, L"linux" ) ) { return; @@ -641,7 +647,7 @@ void reader_write_title() title = function_exists( L"fish_title" )?L"fish_title":DEFAULT_TITLE; - if( wcslen( title ) ==0 ) + if( wcslen( title ) == 0 ) return; al_init( &l );