diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2020-01-27 13:23:53 +0100 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2020-01-27 13:23:53 +0100 |
commit | cafebee579f6a9399fbfcc86e2c89a479aee465e (patch) | |
tree | c15eee478349023a7f33bbfd222a556ab5cfbfe6 /apt-pkg/pkgcachegen.cc | |
parent | 39d17909d2c2e5c720bfe5b92a1639fff4b367d2 (diff) |
NewGroup: Create GrpIterator after allocation (fix segfault)
NewGroup created a GrpIterator and then called WriteStringInMap()
which might remap the cache, causing the iterator to go invalid.
Avoid this simply by creating the iterator later on.
Diffstat (limited to 'apt-pkg/pkgcachegen.cc')
-rw-r--r-- | apt-pkg/pkgcachegen.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 8e0301151..dfac0ae1c 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -557,10 +557,11 @@ bool pkgCacheGenerator::NewGroup(pkgCache::GrpIterator &Grp, StringView Name) if (unlikely(Group == 0)) return false; - Grp = pkgCache::GrpIterator(Cache, Cache.GrpP + Group); map_stringitem_t const idxName = WriteStringInMap(Name); if (unlikely(idxName == 0)) return false; + + Grp = pkgCache::GrpIterator(Cache, Cache.GrpP + Group); Grp->Name = idxName; // Insert it into the hash table |