libiberty: Always return NULL if d_add_substitution fails.
authorMark Wielaard <mark@klomp.org>
Fri, 21 Apr 2017 09:01:56 +0000 (09:01 +0000)
committerMark Wielaard <mark@gcc.gnu.org>
Fri, 21 Apr 2017 09:01:56 +0000 (09:01 +0000)
d_add_substitution can fail for various reasons, like when the subs array
is full. If d_add_substitution fails d_substitution should return NULL
early and not try to continue. Every other call of d_add_substitution
is handled in the same way.

libiberty/ChangeLog:

* cp-demangle.c (d_substitution): Return NULL if d_add_substitution
fails.

From-SVN: r247055

libiberty/ChangeLog
libiberty/cp-demangle.c

index 67ba6e7675a5c56e8357856bb78807929d004b4c..673eb26430105a28574c0eabb3df790242969418 100644 (file)
@@ -1,3 +1,8 @@
+2017-04-21  Mark Wielaard  <mark@klomp.org>
+
+       * cp-demangle.c (d_substitution): Return NULL if d_add_substitution
+       fails.
+
 2017-04-21  Mark Wielaard  <mark@klomp.org>
 
        * cp-demangle.h (struct d_info): Remove did_subs field.
index 2c7d5c5faabe7a8a77096f0a94480024bdba3011..aeff7a79d74eb056fab91712c74e7ab8bd3ce2cd 100644 (file)
@@ -3891,7 +3891,8 @@ d_substitution (struct d_info *di, int prefix)
                  /* If there are ABI tags on the abbreviation, it becomes
                     a substitution candidate.  */
                  dc = d_abi_tags (di, dc);
-                 d_add_substitution (di, dc);
+                 if (! d_add_substitution (di, dc))
+                   return NULL;
                }
              return dc;
            }