From 27cae7715489c13c504590cf77a6d22680dbe0b1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 15 Oct 2012 16:00:44 +0200 Subject: * apt-pkg/pkgcachegen.cc: - Fix crash if the cache is remapped while writing a Provides version (LP: #1066445). --- apt-pkg/pkgcachegen.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 739b538c6..373f6625c 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -975,8 +975,12 @@ bool pkgCacheGenerator::ListParser::NewProvides(pkgCache::VerIterator &Ver, Prv->Version = Ver.Index(); Prv->NextPkgProv = Ver->ProvidesList; Ver->ProvidesList = Prv.Index(); - if (Version.empty() == false && unlikely((Prv->ProvideVersion = WriteString(Version)) == 0)) - return false; + if (Version.empty() == false) { + map_ptrloc const idxProvideVersion = WriteString(Version); + Prv->ProvideVersion = idxProvideVersion; + if (unlikely(idxProvideVersion == 0)) + return false; + } // Locate the target package pkgCache::PkgIterator Pkg; -- cgit v1.2.3-70-g09d2