summaryrefslogtreecommitdiff
path: root/apt-pkg/indexfile.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-06-26 17:47:38 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2017-06-26 23:31:15 +0200
commitf68167a0e55c7261c9e61f0f39945cd0e908dabb (patch)
treeb7a2c179357e56be0248b80c8362dedcff87c40d /apt-pkg/indexfile.cc
parent42654d08c2ca1bee18b6947a39228a35c2409deb (diff)
fix some unlikely memory leaks in error cases
The error cases are just as unlikely as the memory leaks to ever cause real problems, but lets play it safe for correctness. Reported-By: scan-build & clang Gbp-Dch: Ignore
Diffstat (limited to 'apt-pkg/indexfile.cc')
-rw-r--r--apt-pkg/indexfile.cc10
1 files changed, 2 insertions, 8 deletions
diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc
index 934943205..b860e2335 100644
--- a/apt-pkg/indexfile.cc
+++ b/apt-pkg/indexfile.cc
@@ -338,16 +338,10 @@ pkgCacheListParser * pkgDebianIndexFile::CreateListParser(FileFd &Pkg)
if (Pkg.IsOpen() == false)
return nullptr;
_error->PushToStack();
- pkgCacheListParser * const Parser = new debListParser(&Pkg);
+ std::unique_ptr<pkgCacheListParser> Parser(new debListParser(&Pkg));
bool const newError = _error->PendingError();
_error->MergeWithStack();
- if (newError)
- {
- delete Parser;
- return nullptr;
- }
- else
- return Parser;
+ return newError ? nullptr : Parser.release();
}
bool pkgDebianIndexFile::Merge(pkgCacheGenerator &Gen,OpProgress * const Prog)
{