public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, applied] ir: Don't crash when looking at corpus-less translation units
@ 2022-10-26  9:04 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2022-10-26  9:04 UTC (permalink / raw)
  To: libabigail

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-26  9:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26  9:04 [PATCH, applied] ir: Don't crash when looking at corpus-less translation units Dodji Seketeli

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).