strdup to save original

This commit is contained in:
jayden 2023-12-26 00:04:36 +00:00 committed by GitHub
parent a3b48fcf6f
commit 14d7363e79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -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;
}
}