This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH setup 5/5] More crash avoidance in SolvableVersion member functions


The following call-stack means we end up calling SolvableVersion methods
before packagedb::prep(), i.e. before attributes have been internalized, so
their values aren't available.

PickView::init_headers
PickView::refresh
PickView::init
ChooserPage::createListview
ChooserPage::OnInit

We call PickView::refresh again after we've computed the initial solution,
so the columns always end up with the correct width.
---
 libsolv.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libsolv.cc b/libsolv.cc
index 29a26a9..41b42eb 100644
--- a/libsolv.cc
+++ b/libsolv.cc
@@ -172,6 +172,10 @@ SolvableVersion::SDesc () const
     return "";
   Solvable *solvable = pool_id2solvable(pool, id);
   const char *sdesc = repo_lookup_str(solvable->repo, id, SOLVABLE_SUMMARY);
+
+  if (!sdesc)
+    return "";
+
   return sdesc;
 }
 
@@ -225,14 +229,14 @@ SolvableVersion::fixup_spkg_id (SolvableVersion spkg_id) const
 packagesource *
 SolvableVersion::source() const
 {
+  static packagesource empty_source = packagesource();
   if (!id) {
-    static packagesource empty_source = packagesource();
     return &empty_source;
   }
 
   Solvable *solvable = pool_id2solvable(pool, id);
   Id psrc_attr = pool_str2id(pool, "solvable:packagesource", 1);
-  return (packagesource *)repo_lookup_num(solvable->repo, id, psrc_attr, 0);
+  return (packagesource *)repo_lookup_num(solvable->repo, id, psrc_attr, (unsigned long long)&empty_source);
 }
 
 bool
-- 
2.15.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]