From 1bac4fd992ef09510c68996674093f186174f8b7 Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Wed, 26 Aug 2015 08:28:39 +0200 Subject: [PATCH] Harden function_decl::get_pretty_representation() This function can abort when called on a function_decl that is not a member function. This patch addresses that issue. * src/abg-ir.cc (function_decl::get_pretty_representation): Make sure the function type is a member function before calling get_member_function_is_{virtual,ctor,dtor,const}. Signed-off-by: Dodji Seketeli --- src/abg-ir.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 4af4a07c..bf815e66 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -8325,12 +8325,16 @@ function_decl::get_pretty_representation() const string result = mem_fn ? "method ": "function "; - if (get_member_function_is_virtual(mem_fn)) + if (mem_fn + && is_member_function(mem_fn) + && get_member_function_is_virtual(mem_fn)) result += "virtual "; decl_base_sptr type; - if ((mem_fn && (get_member_function_is_dtor(*mem_fn) - || get_member_function_is_ctor(*mem_fn)))) + if ((mem_fn + && is_member_function(mem_fn) + && (get_member_function_is_dtor(*mem_fn) + || get_member_function_is_ctor(*mem_fn)))) /*cdtors do not have return types. */; else type = mem_fn @@ -8395,7 +8399,9 @@ function_decl::get_pretty_representation_of_declarator () const } result += ")"; - if (mem_fn && get_member_function_is_const(*mem_fn)) + if (mem_fn + && is_member_function(mem_fn) + && get_member_function_is_const(*mem_fn)) result += " const"; return result; -- 2.43.5