From ea565fbf4918574921655856b0a4b2ebc16640ba Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sun, 1 Dec 2019 23:29:16 -0500 Subject: [PATCH] Fix an ASan-reported heap corruption --- src/config.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/config.c b/src/config.c index db6eed0..0c7d9ee 100644 --- a/src/config.c +++ b/src/config.c @@ -403,10 +403,11 @@ static bool set_defaults(Config *config) return false; } if (!assembler && !config->sav_path && !config->no_saving) { + const char *ext = ".sav"; config->sav_path = cr_malloc(sizeof(char) * - (strlen(config->rom_path) + 4)); + (strlen(config->rom_path) + strlen(ext) + 1)); strcpy(config->sav_path, config->rom_path); - strcat(config->sav_path, ".sav"); + strcat(config->sav_path, ext); } return true; }