]> sourceware.org Git - libabigail.git/commitdiff
Harden function_decl::get_pretty_representation()
authorDodji Seketeli <dodji@redhat.com>
Wed, 26 Aug 2015 06:28:39 +0000 (08:28 +0200)
committerDodji Seketeli <dodji@redhat.com>
Sat, 29 Aug 2015 14:23:15 +0000 (16:23 +0200)
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 <dodji@redhat.com>
src/abg-ir.cc

index 4af4a07cd6b2b667dc7e442ad674a0377a440fbc..bf815e6629bde7eaee32220b3f9930e63b49cac4 100644 (file)
@@ -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;
This page took 0.045208 seconds and 5 git commands to generate.