From f7e6ce316013850274c956ea51a23d742c42c6f8 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Mon, 7 Jun 2021 14:10:56 +0200 Subject: [PATCH] location:expand() shouldn't crash when no location manager available 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 --- 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.43.5