Skip to content

Commit

Permalink
Merge pull request #312 from oliverkurth/topic/okurth/memleak-fixes
Browse files Browse the repository at this point in the history
Fix a few memory leaks
  • Loading branch information
oliverkurth authored May 3, 2022
2 parents dd2e8bb + b0c6cfc commit ccf0d72
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
2 changes: 0 additions & 2 deletions client/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,6 @@ TDNFReadConfFilesFromDir(
{
continue;
}
dwError = TDNFAllocateStringPrintf(&pszFile, pszDir, pEnt->d_name);
BAIL_ON_TDNF_ERROR(dwError);
dwError = TDNFJoinPath(&pszFile, pszDir, pEnt->d_name, NULL);
BAIL_ON_TDNF_ERROR(dwError);

Expand Down
7 changes: 6 additions & 1 deletion client/goal.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ TDNFMarkAutoInstalled(
{
fclose(fp);
}
TDNF_SAFE_FREE_MEMORY(pszDataDir);
TDNF_SAFE_FREE_MEMORY(pszAutoFile);
TDNF_SAFE_FREE_STRINGARRAY(ppszAutoInstalled);
return dwError;
Expand Down Expand Up @@ -958,7 +959,11 @@ TDNFSolvAddMinVersions(
map_setall(pPool->considered);
map_subtract(pPool->considered, pMapMinVersions);
cleanup:
TDNFFreeMemory(pMapMinVersions);
if(pMapMinVersions)
{
map_free(pMapMinVersions);
TDNFFreeMemory(pMapMinVersions);
}
TDNF_SAFE_FREE_MEMORY(pszTmp);
TDNF_SAFE_FREE_STRINGARRAY(ppszTokens);
return dwError;
Expand Down
8 changes: 8 additions & 0 deletions pytests/tests/test_erase.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ def test_erase_package_without_version_suffix(utils):

utils.run(['tdnf', 'erase', '-y', pkgname])
assert(not utils.check_package(pkgname))


def test_erase_memcheck(utils):
pkgname = utils.config["mulversion_pkgname"]
utils.install_package(pkgname)

utils.run_memcheck(['tdnf', 'erase', '-y', pkgname])
assert(not utils.check_package(pkgname))
8 changes: 8 additions & 0 deletions pytests/tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@ def test_dummy_requires(utils):
pkg = utils.config["dummy_requires_pkgname"]
ret = utils.run(['tdnf', 'install', '-y', pkg])
assert ' nothing provides ' in ret['stderr'][0]


def test_install_memcheck(utils):
pkgname = utils.config["mulversion_pkgname"]
utils.erase_package(pkgname)

utils.run_memcheck(['tdnf', 'install', '-y', '--nogpgcheck', pkgname])
assert(utils.check_package(pkgname))
6 changes: 6 additions & 0 deletions solv/tdnfpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ SolvFreeSack(
Pool* pPool = pSack->pPool;
if(pPool)
{
if (pPool->considered)
{
/* shouldn't this be owned by pPool? */
map_free(pPool->considered);
TDNF_SAFE_FREE_MEMORY(pPool->considered);
}
pool_free(pPool);
}
TDNF_SAFE_FREE_MEMORY(pSack->pszCacheDir);
Expand Down

0 comments on commit ccf0d72

Please sign in to comment.