Browse Source

Fix all memory leaks caused by json_array_append() and json_object_set().

tags/v2.3.0
Andrew Belt 1 year ago
parent
commit
4905496eed
3 changed files with 7 additions and 7 deletions
  1. +2
    -2
      src/app/RackWidget.cpp
  2. +1
    -1
      src/engine/Module.cpp
  3. +4
    -4
      src/library.cpp

+ 2
- 2
src/app/RackWidget.cpp View File

@@ -485,7 +485,7 @@ static PasteJsonResult RackWidget_pasteJson(RackWidget* that, json_t* rootJ, his
if (inputModuleIdIt == newModules.end())
continue;
inputModuleId = inputModuleIdIt->second->module->id;
json_object_set(cableJ, "inputModuleId", json_integer(inputModuleId));
json_object_set_new(cableJ, "inputModuleId", json_integer(inputModuleId));

json_t* outputModuleIdJ = json_object_get(cableJ, "outputModuleId");
if (!outputModuleIdJ)
@@ -495,7 +495,7 @@ static PasteJsonResult RackWidget_pasteJson(RackWidget* that, json_t* rootJ, his
if (outputModuleIdIt == newModules.end())
continue;
outputModuleId = outputModuleIdIt->second->module->id;
json_object_set(cableJ, "outputModuleId", json_integer(outputModuleId));
json_object_set_new(cableJ, "outputModuleId", json_integer(outputModuleId));

// Create Cable
engine::Cable* cable = new engine::Cable;


+ 1
- 1
src/engine/Module.cpp View File

@@ -217,7 +217,7 @@ json_t* Module::paramsToJson() {

json_object_set_new(paramJ, "id", json_integer(paramId));

json_array_append(rootJ, paramJ);
json_array_append_new(rootJ, paramJ);
}
return rootJ;
}


+ 4
- 4
src/library.cpp View File

@@ -66,7 +66,7 @@ void checkAppUpdate() {

std::string versionUrl = API_URL + "/version";
json_t* reqJ = json_object();
json_object_set(reqJ, "edition", json_string(APP_EDITION.c_str()));
json_object_set_new(reqJ, "edition", json_string(APP_EDITION.c_str()));
DEFER({json_decref(reqJ);});

json_t* resJ = network::requestJson(network::METHOD_GET, versionUrl, reqJ);
@@ -115,8 +115,8 @@ void logIn(std::string email, std::string password) {

loginStatus = "Logging in...";
json_t* reqJ = json_object();
json_object_set(reqJ, "email", json_string(email.c_str()));
json_object_set(reqJ, "password", json_string(password.c_str()));
json_object_set_new(reqJ, "email", json_string(email.c_str()));
json_object_set_new(reqJ, "password", json_string(password.c_str()));
std::string url = API_URL + "/token";
json_t* resJ = network::requestJson(network::METHOD_POST, url, reqJ);
json_decref(reqJ);
@@ -196,7 +196,7 @@ void checkUpdates() {
// Get library manifests
std::string manifestsUrl = API_URL + "/library/manifests";
json_t* manifestsReq = json_object();
json_object_set(manifestsReq, "version", json_string(APP_VERSION_MAJOR.c_str()));
json_object_set_new(manifestsReq, "version", json_string(APP_VERSION_MAJOR.c_str()));
json_t* manifestsResJ = network::requestJson(network::METHOD_GET, manifestsUrl, manifestsReq);
json_decref(manifestsReq);
if (!manifestsResJ) {


Loading…
Cancel
Save