summaryrefslogtreecommitdiff
path: root/apt-pkg/deb/dpkgpm.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2011-03-10 10:43:39 +0100
committerMichael Vogt <mvo@debian.org>2011-03-10 10:43:39 +0100
commite9ecab0f97be19326c52f2afe04fd9b44eba01ae (patch)
treead06841a04b112ca93e1ee0a29441214503ce3d2 /apt-pkg/deb/dpkgpm.cc
parent8315b8ccf3b23e5bf78a3ba70154ae721540950c (diff)
parent28166356f30ad13729f7f952e6f1fc6131036591 (diff)
merged from donkult
Diffstat (limited to 'apt-pkg/deb/dpkgpm.cc')
-rw-r--r--apt-pkg/deb/dpkgpm.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 7d0d34a46..7b0955b96 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -881,7 +881,10 @@ bool pkgDPkgPM::Go(int OutStatusFd)
// Generate the argument list
const char *Args[MaxArgs + 50];
-
+ // keep track of allocated strings for multiarch package names
+ char *Packages[MaxArgs + 50];
+ unsigned int pkgcount = 0;
+
// Now check if we are within the MaxArgs limit
//
// this code below is problematic, because it may happen that
@@ -989,13 +992,20 @@ bool pkgDPkgPM::Go(int OutStatusFd)
}
else
{
+ string const nativeArch = _config->Find("APT::Architecture");
for (;I != J && Size < MaxArgBytes; I++)
{
if((*I).Pkg.end() == true)
continue;
if (I->Op == Item::Configure && disappearedPkgs.find(I->Pkg.Name()) != disappearedPkgs.end())
continue;
- Args[n++] = I->Pkg.Name();
+ if (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all"))
+ Args[n++] = I->Pkg.Name();
+ else
+ {
+ Packages[pkgcount] = strdup(I->Pkg.FullName(false).c_str());
+ Args[n++] = Packages[pkgcount++];
+ }
Size += strlen(Args[n-1]);
}
}
@@ -1145,6 +1155,11 @@ bool pkgDPkgPM::Go(int OutStatusFd)
sigemptyset(&sigmask);
sigprocmask(SIG_BLOCK,&sigmask,&original_sigmask);
+ /* clean up the temporary allocation for multiarch package names in
+ the parent, so we don't leak memory when we return. */
+ for (unsigned int i = 0; i < pkgcount; i++)
+ free(Packages[i]);
+
// the result of the waitpid call
int res;
int select_ret;