public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, applied] location:expand() shouldn't crash when no location manager available
@ 2021-06-10  8:28 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2021-06-10  8:28 UTC (permalink / raw)
  To: libabigail

Hello,

While debugging, I noticed that trying to expand location not yet
associated with any location manager would crash.

This patch fixes that.

	* src/abg-ir.cc (location::expand): When no location manager is
	present, just expand to an empty location.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>

Applied to master.
---
 src/abg-ir.cc | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 0f909b3d..f0be0843 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -321,7 +321,16 @@ public:
 void
 location::expand(std::string& path, unsigned& line, unsigned& column) const
 {
-  ABG_ASSERT(get_location_manager());
+  if (!get_location_manager())
+    {
+      // We don't have a location manager maybe because this location
+      // was just freshly instanciated.  We still want to be able to
+      // expand to default values.
+      path = "";
+      line = 0;
+      column = 0;
+      return;
+    }
   get_location_manager()->expand_location(*this, path, line, column);
 }
 
-- 
2.30.0


-- 
		Dodji


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

only message in thread, other threads:[~2021-06-10  8:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10  8:28 [PATCH, applied] location:expand() shouldn't crash when no location manager available 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).