Просмотр исходного кода

apt-pkg/pkgcachegen.cc: copy Arch to avoid segfault on cache remap

Michael Vogt лет назад: 15
Родитель
Сommit
77de0e831a
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      apt-pkg/pkgcachegen.cc

+ 3 - 1
apt-pkg/pkgcachegen.cc

@@ -636,7 +636,9 @@ bool pkgCacheGenerator::FinishCache(OpProgress *Progress)
 	    Dynamic<pkgCache::VerIterator> DynV(V);
 	    Dynamic<pkgCache::VerIterator> DynV(V);
 	    for (; V.end() != true; V++)
 	    for (; V.end() != true; V++)
 	    {
 	    {
-	       char const * const Arch = P.Arch();
+               // copy P.Arch() into a string here as a cache remap
+               // in NewDepends() later may alter the pointer location
+	       string Arch = P.Arch() == NULL ? "" : P.Arch();
 	       map_ptrloc *OldDepLast = NULL;
 	       map_ptrloc *OldDepLast = NULL;
 	       /* MultiArch handling introduces a lot of implicit Dependencies:
 	       /* MultiArch handling introduces a lot of implicit Dependencies:
 		- MultiArch: same → Co-Installable if they have the same version
 		- MultiArch: same → Co-Installable if they have the same version