aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--complete.c35
-rw-r--r--fallback.h13
-rw-r--r--function.c59
3 files changed, 105 insertions, 2 deletions
diff --git a/complete.c b/complete.c
index 145a10b2..8f813012 100644
--- a/complete.c
+++ b/complete.c
@@ -385,10 +385,17 @@ void complete_add( const wchar_t *cmd,
const wchar_t *comp,
const wchar_t *desc )
{
- complete_entry *c =
- complete_find_exact_entry( cmd, cmd_type );
+ complete_entry *c;
complete_entry_opt *opt;
+ if( !cmd )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return;
+ }
+
+ c = complete_find_exact_entry( cmd, cmd_type );
+
if( c == 0 )
{
if( !(c = malloc( sizeof(complete_entry) )))
@@ -453,6 +460,12 @@ void complete_remove( const wchar_t *cmd,
{
complete_entry *e, *eprev=0, *enext=0;
+ if( !cmd )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return;
+ }
+
for( e = first_entry; e; e=enext )
{
enext=e->next;
@@ -598,6 +611,12 @@ int complete_is_valid_option( const wchar_t *str,
int gnu_opt_len=0;
char *short_validated;
+ if( !str || !opt )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return 0;
+ }
+
/*
Check some generic things like -- and - options.
*/
@@ -915,6 +934,12 @@ const wchar_t *complete_get_desc( const wchar_t *filename )
{
struct stat buf;
+ if( !filename )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return 0;
+ }
+
if( !get_desc_buff )
{
get_desc_buff = sb_halloc( global_context);
@@ -1934,6 +1959,12 @@ void complete( const wchar_t *cmd,
int cursor_pos = wcslen(cmd );
+ if( !cmd || !comp )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return;
+ }
+
error_max=0;
/**
diff --git a/fallback.h b/fallback.h
index ff67f68f..42bc3b37 100644
--- a/fallback.h
+++ b/fallback.h
@@ -17,6 +17,19 @@
#endif
/**
+ Make sure __func__ is defined to some string. This should be the
+ currently compiled function, but not all compilers support this
+ feature.
+*/
+#if __STDC_VERSION__ < 199901L
+# if __GNUC__ >= 2
+# define __func__ __FUNCTION__
+# else
+# define __func__ "<unknown>"
+# endif
+#endif
+
+/**
Under curses, tputs expects an int (*func)(char) as its last
parameter, but in ncurses, tputs expects a int (*func)(int) as its
last parameter. tputs_arg_t is defined to always be what tputs
diff --git a/function.c b/function.c
index be42b60d..21fe6a95 100644
--- a/function.c
+++ b/function.c
@@ -157,6 +157,13 @@ void function_add( const wchar_t *name,
wchar_t *cmd_end;
function_data_t *d;
+
+ if( !name || !val )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return;
+ }
+
function_remove( name );
d = malloc( sizeof( function_data_t ) );
@@ -185,6 +192,13 @@ void function_add( const wchar_t *name,
int function_exists( const wchar_t *cmd )
{
+
+ if( !cmd )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return 0;
+ }
+
if( parser_is_reserved(cmd) )
return 0;
@@ -198,6 +212,12 @@ void function_remove( const wchar_t *name )
const void *dv;
function_data_t *d;
event_t ev;
+
+ if( !name )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return;
+ }
hash_remove( &function,
name,
@@ -219,6 +239,13 @@ void function_remove( const wchar_t *name )
const wchar_t *function_get_definition( const wchar_t *argv )
{
function_data_t *data;
+
+ if( !argv )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return 0;
+ }
+
load( argv );
data = (function_data_t *)hash_get( &function, argv );
if( data == 0 )
@@ -229,6 +256,12 @@ const wchar_t *function_get_definition( const wchar_t *argv )
const wchar_t *function_get_desc( const wchar_t *argv )
{
function_data_t *data;
+ if( !argv )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return 0;
+ }
+
load( argv );
data = (function_data_t *)hash_get( &function, argv );
if( data == 0 )
@@ -240,6 +273,12 @@ const wchar_t *function_get_desc( const wchar_t *argv )
void function_set_desc( const wchar_t *name, const wchar_t *desc )
{
function_data_t *data;
+ if( !name || !desc )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return;
+ }
+
load( name );
data = (function_data_t *)hash_get( &function, name );
if( data == 0 )
@@ -294,6 +333,12 @@ static void get_names_internal_all( const void *key,
void function_get_names( array_list_t *list, int get_hidden )
{
+ if( !list )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return;
+ }
+
autoload_names( list, get_hidden );
if( get_hidden )
@@ -310,6 +355,13 @@ void function_get_names( array_list_t *list, int get_hidden )
const wchar_t *function_get_definition_file( const wchar_t *argv )
{
function_data_t *data;
+
+ if( !argv )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return 0;
+ }
+
load( argv );
data = (function_data_t *)hash_get( &function, argv );
if( data == 0 )
@@ -322,6 +374,13 @@ const wchar_t *function_get_definition_file( const wchar_t *argv )
int function_get_definition_offset( const wchar_t *argv )
{
function_data_t *data;
+
+ if( !argv )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return -1;
+ }
+
load( argv );
data = (function_data_t *)hash_get( &function, argv );
if( data == 0 )