X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=libiberty%2Fd-demangle.c;h=becc402c1f82e68445b134ed4910ff9b664f11ec;hb=2f4fcf00399bc0ad5a4fed6b530128e8be4f40da;hp=fe29618f60f79fb3580f8519cdc49c2168aba575;hpb=2a8ae7146cacb006105e2e9c6f4635aca543e7ec;p=deliverable%2Fbinutils-gdb.git diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c index fe29618f60..becc402c1f 100644 --- a/libiberty/d-demangle.c +++ b/libiberty/d-demangle.c @@ -1,5 +1,5 @@ /* Demangler for the D programming language - Copyright (C) 2014-2018 Free Software Foundation, Inc. + Copyright (C) 2014-2019 Free Software Foundation, Inc. Written by Iain Buclaw (ibuclaw@gdcproject.org) This file is part of the libiberty library. @@ -939,8 +939,8 @@ dlang_parse_integer (string *decl, const char *mangled, char type) if (type == 'a' || type == 'u' || type == 'w') { /* Parse character value. */ - char value[10]; - int pos = 10; + char value[20]; + int pos = sizeof(value); int width = 0; long val; @@ -991,7 +991,7 @@ dlang_parse_integer (string *decl, const char *mangled, char type) for (; width > 0; width--) value[--pos] = '0'; - string_appendn (decl, &(value[pos]), 10 - pos); + string_appendn (decl, &(value[pos]), sizeof(value) - pos); } string_append (decl, "'"); } @@ -1191,6 +1191,9 @@ dlang_parse_arrayliteral (string *decl, const char *mangled) while (elements--) { mangled = dlang_value (decl, mangled, NULL, '\0'); + if (mangled == NULL) + return NULL; + if (elements != 0) string_append (decl, ", "); } @@ -1214,8 +1217,13 @@ dlang_parse_assocarray (string *decl, const char *mangled) while (elements--) { mangled = dlang_value (decl, mangled, NULL, '\0'); + if (mangled == NULL) + return NULL; + string_append (decl, ":"); mangled = dlang_value (decl, mangled, NULL, '\0'); + if (mangled == NULL) + return NULL; if (elements != 0) string_append (decl, ", "); @@ -1243,6 +1251,9 @@ dlang_parse_structlit (string *decl, const char *mangled, const char *name) while (args--) { mangled = dlang_value (decl, mangled, NULL, '\0'); + if (mangled == NULL) + return NULL; + if (args != 0) string_append (decl, ", "); } @@ -1497,6 +1508,9 @@ dlang_parse_tuple (string *decl, const char *mangled) while (elements--) { mangled = dlang_type (decl, mangled); + if (mangled == NULL) + return NULL; + if (elements != 0) string_append (decl, ", "); }