public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH, applied] ir: Don't crash when looking at corpus-less translation units
Date: Wed, 26 Oct 2022 11:04:14 +0200	[thread overview]
Message-ID: <874jvrot0x.fsf@redhat.com> (raw)

Hello,

Back in the early days, there was the possibility to have an ABIXML
output that was just a translation unit.  There was no XML corpus
element holding the abi-instr element.  We still need to support this
going forward.

While looking at something else, I stumbled across spots in the source
code that would crash upon encountering such corpus-less ABIXML
inputs.

Fixed thus.

	* src/abg-ir.cc ({decl,type}_topo_comp::operator()): Support types
	that inherits from an empty corpus.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
 src/abg-ir.cc | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index b914faaa..5193934a 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -3353,8 +3353,9 @@ struct decl_topo_comp
 
     // If both decls come from an abixml file, keep the order they
     // have from that abixml file.
-    if (f->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN
-	&& s->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN)
+    if ((!f->get_corpus() && !s->get_corpus())
+	|| (f->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN
+	    && s->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN))
       return compare_using_locations(f, s);
 
     // If a decl has artificial location, then use that one over the
@@ -3451,8 +3452,9 @@ struct type_topo_comp
   {
     // If both decls come from an abixml file, keep the order they
     // have from that abixml file.
-    if (f->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN
-	&& s->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN)
+    if ((!f->get_corpus() && !s->get_corpus())
+	|| (f->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN
+	    && s->get_corpus()->get_origin() == corpus::NATIVE_XML_ORIGIN))
       return compare_using_locations(is_decl(f), is_decl(s));
 
     bool f_is_ptr_ref_or_qual = is_ptr_ref_or_qual_type(f);
-- 
2.38.0


-- 
		Dodji


                 reply	other threads:[~2022-10-26  9:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=874jvrot0x.fsf@redhat.com \
    --to=dodji@redhat.com \
    --cc=libabigail@sourceware.org \
    /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).