Skip to content

Commit

Permalink
Clean all ASAN reported memory problems (curl related) (#416)
Browse files Browse the repository at this point in the history
* Cleanup curl pointer
* Do not duplicate version for gz_TEST
* curl_free missing for decodedPath
* Missing curl_free for encodedRes

---------

Signed-off-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
j-rivero authored Apr 22, 2024
1 parent c7cd3dd commit 8ea43a6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/RestClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ RestResponse Rest::Request(HttpMethod _method,

encodedPath = curl_easy_escape(curl, decodedPath, decodedSize);
url = RestJoinUrl(url, encodedPath);
curl_free(decodedPath);
}

// Process query strings.
Expand Down
3 changes: 3 additions & 0 deletions src/gz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

#include <curl/curl.h>
#include <curl/easy.h>
#include <string.h>
#include <tinyxml2.h>

Expand Down Expand Up @@ -136,8 +137,10 @@ extern "C" void uglyPrint(
std::cout << _serverConfig.Url().Str() << "/" << _serverConfig.Version()
<< "/" << owner->first << "/" << _resourceType << "/"
<< std::string(encodedRes) << std::endl;
curl_free(encodedRes);
}
}
curl_easy_cleanup(curl);
}

//////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/gz_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ std::string custom_exec_str(std::string _cmd)
return result;
}

auto g_version = std::string(strdup(GZ_FUEL_TOOLS_VERSION_FULL));
auto g_version = std::string(GZ_FUEL_TOOLS_VERSION_FULL);
auto g_exec = std::string(GZ_PATH);
auto g_listCmd = g_exec + " fuel list -v 4 --force-version " + g_version;

Expand Down

0 comments on commit 8ea43a6

Please sign in to comment.