From 14d7363e79e9ab871998c0152d6faf4a3d85de7f Mon Sep 17 00:00:00 2001 From: jayden <46307433+krmeet@users.noreply.github.com> Date: Tue, 26 Dec 2023 00:04:36 +0000 Subject: [PATCH 1/2] strdup to save original --- src/pc/mods/mods_utils.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pc/mods/mods_utils.c b/src/pc/mods/mods_utils.c index e04cfa1b..361b7bf5 100644 --- a/src/pc/mods/mods_utils.c +++ b/src/pc/mods/mods_utils.c @@ -44,21 +44,24 @@ static bool mods_incompatible_match(struct Mod* a, struct Mod* b) { return false; } - char* ai = a->incompatible; - char* bi = b->incompatible; + char* ai = strdup(a->incompatible); + char* bi = strdup(b->incompatible); char* atoken = NULL; char* btoken = NULL; char* arest = NULL; char* brest = NULL; for (atoken = strtok_r(ai, " ", &arest); atoken != NULL; atoken = strtok_r(NULL, " ", &arest)) { - for (btoken = strtok_r(bi, " ", &brest); btoken != NULL; btoken = strtok_r(NULL, " ", &brest)) { + for (btoken = strtok_r(bi, " ", &brest); btoken != NULL; btoken = strtok_r(NULL, " ", &brest)) {z if (!strcmp(atoken, btoken)) { return true; } } } + free(ai); + free(bi); + return false; } @@ -330,4 +333,4 @@ bool directory_sanity_check(struct dirent* dir, char* dirPath, char* outPath) { } return true; -} \ No newline at end of file +} From 804837430271e2f7cb7a4e84a42f4878d23fb18f Mon Sep 17 00:00:00 2001 From: jayden <46307433+krmeet@users.noreply.github.com> Date: Tue, 26 Dec 2023 00:06:28 +0000 Subject: [PATCH 2/2] HOW did i let that slide --- src/pc/mods/mods_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pc/mods/mods_utils.c b/src/pc/mods/mods_utils.c index 361b7bf5..833768ae 100644 --- a/src/pc/mods/mods_utils.c +++ b/src/pc/mods/mods_utils.c @@ -52,7 +52,7 @@ static bool mods_incompatible_match(struct Mod* a, struct Mod* b) { char* brest = NULL; for (atoken = strtok_r(ai, " ", &arest); atoken != NULL; atoken = strtok_r(NULL, " ", &arest)) { - for (btoken = strtok_r(bi, " ", &brest); btoken != NULL; btoken = strtok_r(NULL, " ", &brest)) {z + for (btoken = strtok_r(bi, " ", &brest); btoken != NULL; btoken = strtok_r(NULL, " ", &brest)) { if (!strcmp(atoken, btoken)) { return true; }