diff mbox

libiberty: Always return NULL if d_add_substitution fails.

Message ID 1492550465-9322-1-git-send-email-mark@klomp.org
State New
Headers show

Commit Message

Mark Wielaard April 18, 2017, 9:21 p.m. UTC
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.

Comments

Li, Pan2 via Gcc-patches April 18, 2017, 9:46 p.m. UTC | #1
On Tue, Apr 18, 2017 at 2:21 PM, Mark Wielaard <mark@klomp.org> wrote:
> 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.

This is OK.

Thanks.

Ian
diff mbox

Patch

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;
 	    }