From ceb62c05dd7808cc0f2a6b65e7dbfbe0f7c9682d Mon Sep 17 00:00:00 2001 From: David Griffith Date: Sat, 2 Feb 2019 01:00:38 -0800 Subject: [PATCH] Rewrite remaining strcpy() calls in core. I need to remember to free all members of the f_setup and u_setup structures. It seems like the place to do this is in reset_memory() for the core and os_quit() for curses. I should add os_quit() for the other interfaces. --- src/common/files.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/common/files.c b/src/common/files.c index 62892b2..cd54c15 100644 --- a/src/common/files.c +++ b/src/common/files.c @@ -20,6 +20,7 @@ #include #include +#include #include "frotz.h" #ifndef SEEK_SET @@ -74,8 +75,8 @@ void script_open (void) if (!os_read_file_name (new_name, f_setup.script_name, FILE_SCRIPT)) goto done; - strcpy (f_setup.script_name, new_name); - + free(f_setup.script_name); + f_setup.script_name = strdup(new_name); } /* Opening in "at" mode doesn't work for script_erase_input... */ @@ -294,7 +295,8 @@ void record_open (void) if (os_read_file_name (new_name, f_setup.command_name, FILE_RECORD)) { - strcpy (f_setup.command_name, new_name); + free(f_setup.command_name); + f_setup.command_name = strdup(new_name); if ((rfp = fopen (new_name, "wt")) != NULL) ostream_record = TRUE; @@ -418,7 +420,8 @@ void replay_open (void) if (os_read_file_name (new_name, f_setup.command_name, FILE_PLAYBACK)) { - strcpy (f_setup.command_name, new_name); + free(f_setup.command_name); + f_setup.command_name = strdup(new_name); if ((pfp = fopen (new_name, "rt")) != NULL) { -- 2.34.1