X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/19819ac58a420275e0ae9aa7e2a34c72cba8af5e..530302ef25d14bd7577f18cf98c2fa868c3c1dd3:/apt-pkg/pkgcachegen.cc diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index a472babeb..6e307fba9 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -177,6 +177,14 @@ void pkgCacheGenerator::ReMap(void const * const oldMap, void const * const newM for (std::vector::const_iterator i = Dynamic::toReMap.begin(); i != Dynamic::toReMap.end(); ++i) (*i)->ReMap(oldMap, newMap); + for (APT::StringView* ViewP : Dynamic::toReMap) { + // Ignore views outside of the cache. + if (ViewP->data() < static_cast(oldMap) + || ViewP->data() > static_cast(oldMap) + oldSize) + continue; + const char *data = ViewP->data() + (static_cast(newMap) - static_cast(oldMap)); + *ViewP = StringView(data , ViewP->size()); + } } /*}}}*/ // CacheGenerator::WriteStringInMap /*{{{*/ map_stringitem_t pkgCacheGenerator::WriteStringInMap(const char *String, @@ -503,6 +511,7 @@ bool pkgCacheGenerator::AddNewDescription(ListParser &List, pkgCache::VerIterato /* This creates a new group structure and adds it to the hash table */ bool pkgCacheGenerator::NewGroup(pkgCache::GrpIterator &Grp, StringView Name) { + Dynamic DName(Name); Grp = Cache.FindGrp(Name); if (Grp.end() == false) return true; @@ -537,6 +546,8 @@ bool pkgCacheGenerator::NewGroup(pkgCache::GrpIterator &Grp, StringView Name) bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg, StringView Name, StringView Arch) { pkgCache::GrpIterator Grp; + Dynamic DName(Name); + Dynamic DArch(Arch); Dynamic DynGrp(Grp); if (unlikely(NewGroup(Grp, Name) == false)) return false; @@ -649,29 +660,44 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg, StringView Name, if (Arch == "any") { size_t const found = Name.find(':'); - StringView const NameA = Name.substr(0, found); - StringView const ArchA = Name.substr(found + 1); - pkgCache::PkgIterator PkgA = Cache.FindPkg(NameA, ArchA); - if (PkgA.end() == false) + StringView ArchA = Name.substr(found + 1); + if (ArchA != "any") { + // ArchA is used inside the loop which might remap (NameA is not used) + Dynamic DynArchA(ArchA); + StringView NameA = Name.substr(0, found); + pkgCache::PkgIterator PkgA = Cache.FindPkg(NameA, ArchA); Dynamic DynPkgA(PkgA); - pkgCache::PrvIterator Prv = PkgA.ProvidesList(); - for (; Prv.end() == false; ++Prv) + if (PkgA.end()) { - if (Prv.IsMultiArchImplicit()) - continue; - pkgCache::VerIterator V = Prv.OwnerVer(); - if (ArchA != V.ParentPkg().Arch()) - continue; - if (NewProvides(V, Pkg, V->VerStr, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false) + Dynamic DynNameA(NameA); + if (NewPackage(PkgA, NameA, ArchA) == false) return false; } - pkgCache::VerIterator V = PkgA.VersionList(); - Dynamic DynV(V); - for (; V.end() == false; ++V) + if (unlikely(PkgA.end())) + return _error->Fatal("NewPackage was successful for %s:%s," + "but the package doesn't exist anyhow!", + NameA.to_string().c_str(), ArchA.to_string().c_str()); + else { - if (NewProvides(V, Pkg, V->VerStr, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false) - return false; + pkgCache::PrvIterator Prv = PkgA.ProvidesList(); + for (; Prv.end() == false; ++Prv) + { + if (Prv.IsMultiArchImplicit()) + continue; + pkgCache::VerIterator V = Prv.OwnerVer(); + if (ArchA != V.ParentPkg().Arch()) + continue; + if (NewProvides(V, Pkg, V->VerStr, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false) + return false; + } + pkgCache::VerIterator V = PkgA.VersionList(); + Dynamic DynV(V); + for (; V.end() == false; ++V) + { + if (NewProvides(V, Pkg, V->VerStr, pkgCache::Flag::MultiArchImplicit | pkgCache::Flag::ArchSpecific) == false) + return false; + } } } } @@ -1014,6 +1040,9 @@ bool pkgCacheListParser::NewDepends(pkgCache::VerIterator &Ver, { pkgCache::GrpIterator Grp; Dynamic DynGrp(Grp); + Dynamic DynPackageName(PackageName); + Dynamic DynArch(Arch); + Dynamic DynVersion(Version); if (unlikely(Owner->NewGroup(Grp, PackageName) == false)) return false; @@ -1081,6 +1110,9 @@ bool pkgCacheListParser::NewProvides(pkgCache::VerIterator &Ver, uint8_t const Flags) { pkgCache const &Cache = Owner->Cache; + Dynamic DynPkgName(PkgName); + Dynamic DynArch(PkgArch); + Dynamic DynVersion(Version); // We do not add self referencing provides if (Ver.ParentPkg().Name() == PkgName && (PkgArch == Ver.ParentPkg().Arch() || @@ -1134,6 +1166,8 @@ bool pkgCacheListParser::NewProvidesAllArch(pkgCache::VerIterator &Ver, StringVi pkgCache &Cache = Owner->Cache; pkgCache::GrpIterator Grp = Cache.FindGrp(Package); Dynamic DynGrp(Grp); + Dynamic DynPackage(Package); + Dynamic DynVersion(Version); if (Grp.end() == true) return NewProvides(Ver, Package, Cache.NativeArch(), Version, Flags);