d-demangle.c (dlang_parse_integer): Fix stack underflow.

* d-demangle.c (dlang_parse_integer): Fix stack underflow.
     * testsuite/d-demangle-expected: Add testcase.

From-SVN: r270696
This commit is contained in:
Ben L 2019-04-30 14:32:38 +00:00 committed by Jeff Law
parent 80024f3180
commit 81adfd10c9
3 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,8 @@
2019-04-30 Ben L <bobsayshilol@live.co.uk>
* d-demangle.c (dlang_parse_integer): Fix stack underflow.
* testsuite/d-demangle-expected: Add testcase.
* cp-demangle (d_print_comp_inner): Guard against a NULL 'typed_name'.
* testsuite/demangle-expected: Add testcase.

View File

@ -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, "'");
}

View File

@ -1306,3 +1306,7 @@ rt.lifetime._d_newarrayOpT!(_d_newarrayiT)._d_newarrayOpT(const(TypeInfo), ulong
--format=dlang
_D4core8demangle16__T6mangleTFZPvZ6mangleFNaNbNfAxaAaZ11DotSplitter5emptyMxFNaNbNdNiNfZb
core.demangle.mangle!(void*() function).mangle(const(char)[], char[]).DotSplitter.empty() const
# Could crash
--format=dlang
_D8__T2fnVa8888888888888_
_D8__T2fnVa8888888888888_