diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-07-10 16:37:21 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-07-10 16:37:21 +0100 |
commit | 15e52b9ed701bea7b37bdacc8b3898cfb9399460 (patch) | |
tree | 0d3dc4ea113bf0ba488049e15386dd982dc1e9e7 | |
parent | Ensure findPackages query is drained incase it's reused (diff) | |
download | gentoobrowse-api-15e52b9ed701bea7b37bdacc8b3898cfb9399460.tar.bz2 gentoobrowse-api-15e52b9ed701bea7b37bdacc8b3898cfb9399460.tar.xz gentoobrowse-api-15e52b9ed701bea7b37bdacc8b3898cfb9399460.zip |
Fix memory leak in Git::throwError
-rw-r--r-- | gentoobrowse-api/service/utils/git.cpp | 4 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testUtils.cpp | 6 |
2 files changed, 9 insertions, 1 deletions
diff --git a/gentoobrowse-api/service/utils/git.cpp b/gentoobrowse-api/service/utils/git.cpp index 52c31d1..6e2e04e 100644 --- a/gentoobrowse-api/service/utils/git.cpp +++ b/gentoobrowse-api/service/utils/git.cpp @@ -13,7 +13,9 @@ namespace Gentoo { char ** fn = backtrace_symbols(&func, 1); assert(fn); assert(*fn); - throw ::Gentoo::GitError(*fn, err, e->klass, e->message); + std::string funcName(*fn); + free(fn); + throw ::Gentoo::GitError(funcName, err, e->klass, e->message); } std::string diff --git a/gentoobrowse-api/unittests/testUtils.cpp b/gentoobrowse-api/unittests/testUtils.cpp index e89f0fb..5109d48 100644 --- a/gentoobrowse-api/unittests/testUtils.cpp +++ b/gentoobrowse-api/unittests/testUtils.cpp @@ -2,12 +2,15 @@ #include <boost/test/unit_test.hpp> #include <utils/git.h> +#include <libxml/parser.h> #include <maintenance.h> using namespace Gentoo::Utils::Git; BOOST_AUTO_TEST_CASE( gitErrorMessage ) { + xmlInitParser(); + try { gitSafeGet(git_repository_open_ext, git_repository_free, "/", 0, nullptr); } @@ -19,5 +22,8 @@ BOOST_AUTO_TEST_CASE( gitErrorMessage ) BOOST_REQUIRE(ge.message.find("repository") + 1); } } + + xmlCleanupParser(); + git_libgit2_shutdown(); } |