summaryrefslogtreecommitdiff
path: root/apt-pkg/edsp
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/edsp
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/edsp')
-rw-r--r--apt-pkg/edsp/edspindexfile.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/apt-pkg/edsp/edspindexfile.cc b/apt-pkg/edsp/edspindexfile.cc
index 042a88cf9..2d030daaf 100644
--- a/apt-pkg/edsp/edspindexfile.cc
+++ b/apt-pkg/edsp/edspindexfile.cc
@@ -18,6 +18,7 @@
#include <stddef.h>
#include <unistd.h>
+#include <memory>
#include <string>
/*}}}*/
@@ -61,12 +62,12 @@ std::string edspIndex::GetComponent() const
pkgCacheListParser * edspIndex::CreateListParser(FileFd &Pkg)
{
if (Pkg.IsOpen() == false)
- return NULL;
+ return nullptr;
_error->PushToStack();
- pkgCacheListParser * const Parser = new edspListParser(&Pkg);
+ std::unique_ptr<pkgCacheListParser> Parser(new edspListParser(&Pkg));
bool const newError = _error->PendingError();
_error->MergeWithStack();
- return newError ? NULL : Parser;
+ return newError ? nullptr : Parser.release();
}
/*}}}*/
// EIPP Index /*{{{*/
@@ -80,12 +81,12 @@ std::string eippIndex::GetComponent() const
pkgCacheListParser * eippIndex::CreateListParser(FileFd &Pkg)
{
if (Pkg.IsOpen() == false)
- return NULL;
+ return nullptr;
_error->PushToStack();
- pkgCacheListParser * const Parser = new eippListParser(&Pkg);
+ std::unique_ptr<pkgCacheListParser> Parser(new eippListParser(&Pkg));
bool const newError = _error->PendingError();
_error->MergeWithStack();
- return newError ? NULL : Parser;
+ return newError ? nullptr : Parser.release();
}
/*}}}*/