From 022e77fee802dfc50b8dce51ac10ea0597f7a64a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 6 Mar 2006 13:15:46 +0100 Subject: Fixed error handling on empty help topics. (See #109) --- help.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'help.c') diff --git a/help.c b/help.c index 8959a70b..7c6d2dda 100644 --- a/help.c +++ b/help.c @@ -115,22 +115,21 @@ char *help_get( help_t **help, char *string ) if( g_strcasecmp( h->string, string ) == 0 ) break; h = h->next; } - if( h ) + if( h && h->length > 0 ) { char *s = g_new( char, h->length + 1 ); if( fstat( h->fd, stat ) != 0 ) { g_free( h ); - *help=NULL; - return( NULL ); + *help = NULL; + return NULL; } mtime = stat->st_mtime; - if( mtime > h->mtime ) { - return( NULL ); - return( g_strdup( "Help file changed during this session. Please restart to get help back." ) ); - } + if( mtime > h->mtime ) + return NULL; + s[h->length] = 0; if( h->fd >= 0 ) { @@ -141,8 +140,8 @@ char *help_get( help_t **help, char *string ) { strncpy( s, h->offset.mem_offset, h->length ); } - return( s ); + return s; } - return( NULL ); + return NULL; } -- cgit v1.2.3