From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH setup 5/5] More crash avoidance in SolvableVersion member functions
Date: Tue, 07 Nov 2017 18:17:00 -0000 [thread overview]
Message-ID: <20171107181703.51016-5-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20171107181703.51016-1-jon.turney@dronecode.org.uk>
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
next prev parent reply other threads:[~2017-11-07 18:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-01 20:38 [setup topic/libsolv] Crash after incomplete download Ken Brown
2017-11-02 17:22 ` Jon Turney
2017-11-02 19:25 ` Ken Brown
2017-11-07 18:15 ` Jon Turney
2017-11-07 18:17 ` [PATCH setup 1/5] Make do_ini() succeed if found_ini_list is empty Jon Turney
2017-11-07 18:17 ` Jon Turney [this message]
2017-11-07 18:17 ` [PATCH setup 3/5] Ensure packagedb and underlying solver pool is empty before we read setup.ini Jon Turney
2017-11-07 18:17 ` [PATCH setup 4/5] Correctly order preparing packagedb for chooser Jon Turney
2017-11-07 18:17 ` [PATCH setup 2/5] Simplify LocalDirPage::OnNext() Jon Turney
2017-11-07 23:00 ` [setup topic/libsolv] Crash after incomplete download Ken Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171107181703.51016-5-jon.turney@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--cc=cygwin-apps@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).