fixed one remaining memory leak from checkVersion

lmao I thought the memory leak was bug in json-c :DD
This commit is contained in:
Václav Šmejkal 2023-01-27 15:10:20 +01:00
parent b50ed767ac
commit 5c50174212
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -161,7 +161,7 @@ boolean checkVersion(void)
fclose(fileBuffer); fclose(fileBuffer);
//GET //GET
parsedJson = json_tokener_parse(buffer); parsedJson = json_tokener_parse(buffer); //yes, ik, i could use json_object_from_file, but I need to check for internet somehow
json_object_object_get_ex(parsedJson, "active", &active); json_object_object_get_ex(parsedJson, "active", &active);
if (strcmp(VERSION, json_object_get_string(active)) != 0) if (strcmp(VERSION, json_object_get_string(active)) != 0)
@ -248,7 +248,6 @@ boolean checkVersion(void)
{ {
if (!getFlags().noOutput) printf("Version %s not found! Check your flags.\n\n", VERSION); if (!getFlags().noOutput) printf("Version %s not found! Check your flags.\n\n", VERSION);
free(deprecated);
goto deallocation; goto deallocation;
} }
@ -258,15 +257,13 @@ boolean checkVersion(void)
if (!getFlags().noOutput) fprintf(stderr, "This release could be unsafe! You're %d versions behind! (%s/%s)\n\n", versionsBuffer, VERSION, json_object_get_string(active)); if (!getFlags().noOutput) fprintf(stderr, "This release could be unsafe! You're %d versions behind! (%s/%s)\n\n", versionsBuffer, VERSION, json_object_get_string(active));
//WAIT FOR 5 SECONDS //WAIT FOR 5 SECONDS
free(deprecated);
sleep(5); sleep(5);
} }
deallocation: deallocation:
//DEALLOCATION //DEALLOCATION
free(parsedJson); json_object_put(parsedJson); //THIS FREES EVERY json_object - AT LEAST JSON-C'S DOCUMENTATION SAYS THAT
free(active);
free(buffer); free(buffer);
return SUCCESS; return SUCCESS;