aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-09-01 18:14:04 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-09-01 18:14:04 +0000
commit2bcd65ecf6a8505ade08aa39efe41a0361eaf84a (patch)
tree4740d96a1c6c4b2f72402493cda980e4816109a9
parente1a6fb787059848c815a8154da23b7da794c6231 (diff)
* `nix-env -e' corrupts memory due to incorrect use of iterators.
Reported by Rob Vermaas.
-rw-r--r--src/nix-env/main.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc
index 4676f0131..96bbce5cf 100644
--- a/src/nix-env/main.cc
+++ b/src/nix-env/main.cc
@@ -584,23 +584,27 @@ static void uninstallDerivations(Globals & globals, DrvNames & selectors,
Path & profile)
{
UserEnvElems installedElems = queryInstalled(globals.state, profile);
+ UserEnvElems newElems;
for (UserEnvElems::iterator i = installedElems.begin();
i != installedElems.end(); ++i)
{
DrvName drvName(i->second.name);
+ bool found = false;
for (DrvNames::iterator j = selectors.begin();
j != selectors.end(); ++j)
if (j->matches(drvName)) {
printMsg(lvlInfo,
format("uninstalling `%1%'") % i->second.name);
- installedElems.erase(i);
+ found = true;
+ break;
}
+ if (!found) newElems.insert(*i);
}
if (globals.dryRun) return;
- createUserEnv(globals.state, installedElems,
+ createUserEnv(globals.state, newElems,
profile, globals.keepDerivations);
}