summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerman Semenoff <GermanAizek@yandex.ru>2026-04-08 13:09:52 +0300
committerJulian Andres Klode <jak@debian.org>2026-05-01 16:27:11 +0000
commite79f9bb22375fd72330b534e17dcd3ceace432e8 (patch)
tree467777a1a76219fe40e7dc247039773e24771951
parent8915e23a8f8c44bfba4dd42f77b9695120216820 (diff)
apt-pkg: methods: fixed many minor memleaks
Static analysis has shown that there are many minor memleaks.
-rw-r--r--apt-pkg/contrib/cdromutl.cc1
-rw-r--r--apt-pkg/dirstream.cc1
-rw-r--r--apt-pkg/indexcopy.cc1
-rw-r--r--apt-pkg/pkgsystem.cc5
-rw-r--r--methods/connect.cc3
5 files changed, 10 insertions, 1 deletions
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index ff8fb4835..60d137930 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -255,6 +255,7 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
closedir(D);
Res = Hash.GetHashString(Hashes::MD5SUM).HashValue().append(std::move(S));
+ close(dirfd);
return true;
}
/*}}}*/
diff --git a/apt-pkg/dirstream.cc b/apt-pkg/dirstream.cc
index ef9f08ebc..b71a34d3e 100644
--- a/apt-pkg/dirstream.cc
+++ b/apt-pkg/dirstream.cc
@@ -53,6 +53,7 @@ bool pkgDirStream::DoItem(Item &Itm,int &Fd)
return _error->Errno("fchown",_("Failed to write file %s"), Itm.Name);
}
Fd = iFd;
+ close(iFd);
return true;
}
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index 089bfd2ce..636393dd6 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -573,6 +573,7 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
pid_t pid = ExecFork();
if(pid < 0) {
_error->Error("Fork failed");
+ delete MetaIndex;
return false;
}
if(pid == 0)
diff --git a/apt-pkg/pkgsystem.cc b/apt-pkg/pkgsystem.cc
index 7e48a68c7..4bc05d19b 100644
--- a/apt-pkg/pkgsystem.cc
+++ b/apt-pkg/pkgsystem.cc
@@ -69,4 +69,7 @@ map_id_t pkgSystem::GetVersionMapping(map_id_t const in) const
return (o == d->idmap.end()) ? in : o->second;
}
/*}}}*/
-pkgSystem::~pkgSystem() {}
+pkgSystem::~pkgSystem()
+{
+ delete d;
+}
diff --git a/methods/connect.cc b/methods/connect.cc
index 828be3f50..7e740e398 100644
--- a/methods/connect.cc
+++ b/methods/connect.cc
@@ -1011,7 +1011,10 @@ ResultState UnwrapTLS(std::string const &Host, std::unique_ptr<MethodFd> &Fd,
if (auto ctx = GetContextForHost(Host, OwnerConf))
tlsFd->ssl = SSL_new(ctx);
else
+ {
+ delete tlsFd;
return ResultState::FATAL_ERROR;
+ }
FdFd *fdfd = dynamic_cast<FdFd *>(Fd.get());
if (fdfd != nullptr)