mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
cleanup: Minor fixes in test code.
* Buffer overrun in auto test. * Resource leak in AFL test code.
This commit is contained in:
parent
01ea27085f
commit
cdc0286050
|
@ -132,7 +132,7 @@ static void test_save_compatibility(const char *save_path)
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char base_path[4096];
|
||||
char base_path[4096] = {0};
|
||||
|
||||
if (argc <= 1) {
|
||||
const char *srcdir = getenv("srcdir");
|
||||
|
@ -141,10 +141,10 @@ int main(int argc, char *argv[])
|
|||
srcdir = ".";
|
||||
}
|
||||
|
||||
strcpy(base_path, srcdir);
|
||||
snprintf(base_path, sizeof(base_path), "%s", srcdir);
|
||||
} else {
|
||||
strcpy(base_path, argv[1]);
|
||||
base_path[strrchr(base_path, '/') - base_path] = 0;
|
||||
snprintf(base_path, sizeof(base_path), "%s", argv[1]);
|
||||
base_path[strrchr(base_path, '/') - base_path] = '\0';
|
||||
}
|
||||
|
||||
char save_path[4096 + sizeof(LOADED_SAVE_FILE)];
|
||||
|
|
|
@ -20,6 +20,7 @@ int main(int argc, char **argv)
|
|||
size_t bytes_read = fread(buffer, filelen, 1, fileptr);
|
||||
|
||||
if (bytes_read != filelen) {
|
||||
fclose(fileptr);
|
||||
free(buffer);
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user