* `nix-env -e' corrupts memory due to incorrect use of iterators.
Reported by Rob Vermaas.
This commit is contained in:
parent
e1a6fb7870
commit
2bcd65ecf6
1 changed files with 6 additions and 2 deletions
|
@ -584,23 +584,27 @@ static void uninstallDerivations(Globals & globals, DrvNames & selectors,
|
||||||
Path & profile)
|
Path & profile)
|
||||||
{
|
{
|
||||||
UserEnvElems installedElems = queryInstalled(globals.state, profile);
|
UserEnvElems installedElems = queryInstalled(globals.state, profile);
|
||||||
|
UserEnvElems newElems;
|
||||||
|
|
||||||
for (UserEnvElems::iterator i = installedElems.begin();
|
for (UserEnvElems::iterator i = installedElems.begin();
|
||||||
i != installedElems.end(); ++i)
|
i != installedElems.end(); ++i)
|
||||||
{
|
{
|
||||||
DrvName drvName(i->second.name);
|
DrvName drvName(i->second.name);
|
||||||
|
bool found = false;
|
||||||
for (DrvNames::iterator j = selectors.begin();
|
for (DrvNames::iterator j = selectors.begin();
|
||||||
j != selectors.end(); ++j)
|
j != selectors.end(); ++j)
|
||||||
if (j->matches(drvName)) {
|
if (j->matches(drvName)) {
|
||||||
printMsg(lvlInfo,
|
printMsg(lvlInfo,
|
||||||
format("uninstalling `%1%'") % i->second.name);
|
format("uninstalling `%1%'") % i->second.name);
|
||||||
installedElems.erase(i);
|
found = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if (!found) newElems.insert(*i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globals.dryRun) return;
|
if (globals.dryRun) return;
|
||||||
|
|
||||||
createUserEnv(globals.state, installedElems,
|
createUserEnv(globals.state, newElems,
|
||||||
profile, globals.keepDerivations);
|
profile, globals.keepDerivations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue