From c48ef8942d87388a67af9e2cad92171aca3be731 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 25 Mar 2016 13:08:06 +0100 Subject: don't leak on error in listparser creation Git-Dch: Ignore Reported-By: gcc -fsanitize=address --- apt-pkg/indexfile.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'apt-pkg/indexfile.cc') diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc index 657cdfb36..894671bae 100644 --- a/apt-pkg/indexfile.cc +++ b/apt-pkg/indexfile.cc @@ -325,12 +325,18 @@ pkgDebianIndexFile::~pkgDebianIndexFile() pkgCacheListParser * pkgDebianIndexFile::CreateListParser(FileFd &Pkg) { if (Pkg.IsOpen() == false) - return NULL; + return nullptr; _error->PushToStack(); pkgCacheListParser * const Parser = new debListParser(&Pkg); bool const newError = _error->PendingError(); _error->MergeWithStack(); - return newError ? NULL : Parser; + if (newError) + { + delete Parser; + return nullptr; + } + else + return Parser; } bool pkgDebianIndexFile::Merge(pkgCacheGenerator &Gen,OpProgress * const Prog) { -- cgit v1.2.3