aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2017-04-21 09:01:56 +0000
committerMark Wielaard <mark@gcc.gnu.org>2017-04-21 09:01:56 +0000
commit13b6ef76dc275232310ebfca27db08aeef9b858c (patch)
treea7877742e13eda04830c6b97ef5b5822412562dd
parent1240212c6b2ad61a9f8f918192fbb67d45405cc2 (diff)
downloadgcc-13b6ef76dc275232310ebfca27db08aeef9b858c.zip
gcc-13b6ef76dc275232310ebfca27db08aeef9b858c.tar.gz
gcc-13b6ef76dc275232310ebfca27db08aeef9b858c.tar.bz2
libiberty: Always return NULL if d_add_substitution fails.
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
-rw-r--r--libiberty/ChangeLog5
-rw-r--r--libiberty/cp-demangle.c3
2 files changed, 7 insertions, 1 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 67ba6e7..673eb26 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,5 +1,10 @@
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.
* cp-demangle.c (struct d_info_checkpoint): Likewise.
(d_template_param): Don't update did_subs.
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 2c7d5c5..aeff7a7 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -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;
}