diff mbox series

[applied] location:expand() shouldn't crash when no location manager available

Message ID 87v96m2keq.fsf@redhat.com
State New
Headers show
Series [applied] location:expand() shouldn't crash when no location manager available | expand

Commit Message

Dodji Seketeli June 10, 2021, 8:28 a.m. UTC
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 mbox series

Patch

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);
 }