[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    extragear/sysadmin/libqapt/src
From:       Jonathan Michael Thomas <echidnaman () kubuntu ! org>
Date:       2010-12-11 23:04:37
Message-ID: 20101211230437.BF7B0AC8A7 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1205641 by jmthomas:

Check to see if the VerIterator we get from the state cache is valid or not. If it's \
a purely virtual package it will not be in the depCache, and will crash us when we \
try to access it


 M  +33 -3     package.cpp  


--- trunk/extragear/sysadmin/libqapt/src/package.cpp #1205640:1205641
@@ -763,8 +763,18 @@
     pkgDepCache::StateCache & State = (*d->depCache)[*d->packageIter];
     Ver = State.CandidateVerIter(*d->depCache);
 
+    if (Ver.end()) {
+        return recommends;
+    }
+
     for(pkgCache::DepIterator it = Ver.DependsList(); !it.end(); ++it) {
-        pkgDepCache::StateCache &rState = (*d->depCache)[it.TargetPkg()];
+        pkgCache::PkgIterator pkg = it.TargetPkg();
+
+        // Skip purely virtual packages
+        if (!pkg->VersionList) {
+            continue;
+        }
+        pkgDepCache::StateCache &rState = (*d->depCache)[pkg];
         if (it->Type == pkgCache::Dep::Recommends && (rState.CandidateVer != 0 )) {
             recommends << QString::fromStdString(it.TargetPkg().Name());
         }
@@ -781,8 +791,18 @@
     pkgDepCache::StateCache & State = (*d->depCache)[*d->packageIter];
     Ver = State.CandidateVerIter(*d->depCache);
 
+    if (Ver.end()) {
+        return suggests;
+    }
+
     for(pkgCache::DepIterator it = Ver.DependsList(); !it.end(); ++it) {
-        pkgDepCache::StateCache &sState = (*d->depCache)[it.TargetPkg()];
+        pkgCache::PkgIterator pkg = it.TargetPkg();
+
+        // Skip purely virtual packages
+        if (!pkg->VersionList) {
+            continue;
+        }
+        pkgDepCache::StateCache &sState = (*d->depCache)[pkg];
         if (it->Type == pkgCache::Dep::Suggests && (sState.CandidateVer != 0 )) {
             suggests << QString::fromStdString(it.TargetPkg().Name());
         }
@@ -799,8 +819,18 @@
     pkgDepCache::StateCache & State = (*d->depCache)[*d->packageIter];
     Ver = State.CandidateVerIter(*d->depCache);
 
+    if (Ver.end()) {
+        return enhances;
+    }
+
     for(pkgCache::DepIterator it = Ver.DependsList(); !it.end(); ++it) {
-        pkgDepCache::StateCache &eState = (*d->depCache)[it.TargetPkg()];
+        pkgCache::PkgIterator pkg = it.TargetPkg();
+
+        // Skip purely virtual packages
+        if (!pkg->VersionList) {
+            continue;
+        }
+        pkgDepCache::StateCache &eState = (*d->depCache)[pkg];
         if (it->Type == pkgCache::Dep::Enhances && (eState.CandidateVer != 0 )) {
             enhances << QString::fromStdString(it.TargetPkg().Name());
         }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic