This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 6/7] Fix DEMANGLE_COMPONENT_LOCAL_NAME


On 07/06/2015 01:39 PM, Mikhail Maltsev wrote:
---
  libiberty/cp-demangle.c               | 7 +++++++
  libiberty/testsuite/demangle-expected | 4 ++++
  2 files changed, 11 insertions(+)

diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 424b1c5..289a704 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -3243,6 +3243,8 @@ d_expression_1 (struct d_info *di)
  	    struct demangle_component *left;
  	    struct demangle_component *right;

+	    if (code == NULL)
+	      return NULL;
  	    if (op_is_new_cast (op))
  	      left = cplus_demangle_type (di);
  	    else
@@ -4436,6 +4438,11 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
  	    local_name = d_right (typed_name);
  	    if (local_name->type == DEMANGLE_COMPONENT_DEFAULT_ARG)
  	      local_name = local_name->u.s_unary_num.sub;
+	    if (local_name == NULL)
+	      {
+		d_print_error (dpi);
+		return;
+	      }
  	    while (local_name->type == DEMANGLE_COMPONENT_RESTRICT_THIS
  		   || local_name->type == DEMANGLE_COMPONENT_VOLATILE_THIS
  		   || local_name->type == DEMANGLE_COMPONENT_CONST_THIS
diff --git a/libiberty/testsuite/demangle-expected
b/libiberty/testsuite/demangle-expected
index 2dbab14..cfa2691 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -4104,6 +4104,10 @@ _Z11111111111
  --format=gnu-v3
  _ZDTtl
  _ZDTtl
+# Check for NULL pointer when demangling DEMANGLE_COMPONENT_LOCAL_NAME
+--format=gnu-v3
+_ZZN1fEEd_lEv
+_ZZN1fEEd_lEv
  #
  # Ada (GNAT) tests.
  #

Also OK with a suitable ChangeLog entry.

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]