Potential fix for #172

Adds a null-terminator to gCLIOpts.ConfigFile
This commit is contained in:
Vinícius R. Miguel 2020-05-17 23:55:17 -03:00
parent d6495550f5
commit ba04643b61
1 changed files with 2 additions and 0 deletions

View File

@ -13,6 +13,7 @@ void parse_cli_opts(int argc, char* argv[])
gCLIOpts.FullScreen = 0;
gCLIOpts.ConfigFile = malloc(31);
strncpy(gCLIOpts.ConfigFile, "sm64config.txt", strlen("sm64config.txt"));
gCLIOpts.ConfigFile[strlen("sm64config.txt") + 1] = '\0';
// Scan arguments for options
if (argc > 1)
@ -48,6 +49,7 @@ void parse_cli_opts(int argc, char* argv[])
} else {
memset(gCLIOpts.ConfigFile, 0, 30);
strncpy(gCLIOpts.ConfigFile, argv[i+1], strlen(argv[i+1]));
gCLIOpts.ConfigFile[strlen(argv[i+1]) + 1] = '\0';
}
}
}