From: Bill Lash Date: Tue, 18 Dec 2018 01:52:42 +0000 (-0600) Subject: Check for NULL pointer when stripping extension X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=244804b07248cae5c00f9a494c8c8b1e8f5df3b5;p=liskon_frotz.git Check for NULL pointer when stripping extension When stripping the story file extension, verify that the strrchr() found the ".". This ensures that if the file had no extension, ther will be no SEGFAULT. --- diff --git a/src/curses/ux_init.c b/src/curses/ux_init.c index 98aa140..72616dc 100644 --- a/src/curses/ux_init.c +++ b/src/curses/ux_init.c @@ -332,7 +332,10 @@ void os_process_arguments (int argc, char *argv[]) /* Now strip off the extension */ p = strrchr(f_setup.story_name, '.'); - *p = '\0'; /* extension removed */ + if ( p != NULL ) + { + *p = '\0'; /* extension removed */ + } /* Create nice default file names */ diff --git a/src/dumb/dumb_init.c b/src/dumb/dumb_init.c index 9b8f74f..13b1de9 100644 --- a/src/dumb/dumb_init.c +++ b/src/dumb/dumb_init.c @@ -146,7 +146,10 @@ void os_process_arguments(int argc, char *argv[]) /* Now strip off the extension */ p = strrchr(f_setup.story_name, '.'); - *p = '\0'; /* extension removed */ + if ( p != NULL ) + { + *p = '\0'; /* extension removed */ + } /* Create nice default file names */