[gnome-software/wip/ubuntu] apt: Check the iterators are good before accessing them



commit 7374bdc88f86f7378b624ee057076774e23ae62d
Author: Iain Lane <iain orangesquash org uk>
Date:   Fri Sep 23 14:12:18 2016 +0100

    apt: Check the iterators are good before accessing them
    
    Fixes a crash.
    
    https://bugs.launchpad.net/ubuntu/+source/gnome-software/+bug/1571729

 src/plugins/gs-plugin-apt.cc |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/gs-plugin-apt.cc b/src/plugins/gs-plugin-apt.cc
index 442b6d2..5595340 100644
--- a/src/plugins/gs-plugin-apt.cc
+++ b/src/plugins/gs-plugin-apt.cc
@@ -338,7 +338,7 @@ look_at_pkg (const pkgCache::PkgIterator &P,
 
        PackageInfo *info;
 
-       if (!candidate || !candidate.FileList ())
+       if (!candidate || !candidate.IsGood () || !candidate.FileList ())
                return TRUE;
 
        name = g_strdup (P.Name ());
@@ -377,7 +377,7 @@ look_at_pkg (const pkgCache::PkgIterator &P,
 
        pkgTagFile TagF (&PkgF);
 
-       if (TagF.Jump (Tags, current.FileList ()->Offset) == false) {
+       if (!current.IsGood() || TagF.Jump (Tags, current.FileList ()->Offset) == false) {
                if (TagF.Jump (Tags, candidate.FileList ()->Offset) == false)
                        return TRUE;
        }
@@ -387,7 +387,7 @@ look_at_pkg (const pkgCache::PkgIterator &P,
        else
                info->installed_size = 0;
 
-       if (current)
+       if (current && current.IsGood ())
                info->installed_version = g_strdup (current.VerStr ());
        if (candidate)
                info->update_version = g_strdup (candidate.VerStr ());


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]