From 92fde30c0c4ac336aff8eda08f9e164b0f5761d9 Mon Sep 17 00:00:00 2001 From: axel Date: Wed, 3 May 2006 02:28:30 +1000 Subject: [PATCH] Fix segfault when using the 'set' command with no arguments darcs-hash:20060502162830-ac50b-d3ab63c29a6daeaa62803923b060ec69942911f8.gz --- builtin_set.c | 2 +- common.c | 6 ++++++ common.h | 4 +++- fallback.h | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/builtin_set.c b/builtin_set.c index 8aabc4031..ab6e7e6ae 100644 --- a/builtin_set.c +++ b/builtin_set.c @@ -491,7 +491,7 @@ int builtin_set( wchar_t **argv ) al_push(&values, argv[woptind++]); } - if( is_path_variable( dest ) ) + if( dest && is_path_variable( dest ) ) { int i; int error = 0; diff --git a/common.c b/common.c index 0bb4a021a..d4d5827cc 100644 --- a/common.c +++ b/common.c @@ -495,6 +495,12 @@ int contains_str( const wchar_t *a, ... ) wchar_t *arg; va_list va; int res = 0; + + if( !a ) + { + debug( 1, L"Warning: Called contains_str with null argument. This is a bug." ); + return 0; + } va_start( va, a ); while( (arg=va_arg(va, wchar_t *) )!= 0 ) diff --git a/common.h b/common.h index 60bcb8787..cb7e9d0ad 100644 --- a/common.h +++ b/common.h @@ -181,9 +181,11 @@ void error_reset(); const wchar_t *wsetlocale( int category, const wchar_t *locale ); /** - Checks if \c needle is included in the list of strings specified + Checks if \c needle is included in the list of strings specified. A warning is printed if needle is zero. \param needle the string to search for in the list + + \return zero is needle is not found, of if needle is null, non-zero otherwise */ int contains_str( const wchar_t *needle, ... ); diff --git a/fallback.h b/fallback.h index 262ca8817..3ec46666a 100644 --- a/fallback.h +++ b/fallback.h @@ -6,7 +6,7 @@ #include #include #include -#include "common.h" + /** Under curses, tputs expects an int (*func)(char) as its last