From 244804b07248cae5c00f9a494c8c8b1e8f5df3b5 Mon Sep 17 00:00:00 2001 From: Bill Lash Date: Mon, 17 Dec 2018 19:52:42 -0600 Subject: [PATCH] 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. --- src/curses/ux_init.c | 5 ++++- src/dumb/dumb_init.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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 */ -- 2.34.1