libiberty: prevent null dereferencing on dlang_type

libiberty/
	* d-demangle.c (dlang_Type): Validate MANGLED is nonnull.

	* testsuite/d-demangle-expected: New test.
This commit is contained in:
Luís Ferreira 2021-09-23 11:54:00 -04:00 committed by Jeff Law
parent 5481040197
commit b3585c0836
2 changed files with 6 additions and 3 deletions

View File

@ -875,7 +875,7 @@ dlang_type (string *decl, const char *mangled, struct dlang_info *info)
szmods = string_length (&mods);
/* Back referenced function type. */
if (*mangled == 'Q')
if (mangled && *mangled == 'Q')
mangled = dlang_type_backref (decl, mangled, info, 1);
else
mangled = dlang_function_type (decl, mangled, info);

View File

@ -991,9 +991,12 @@ _D88
_D5__T1aZv
_D5__T1aZv
#
_D00
_D00
#
--format=dlang
_D00
_D00
_D01_D
_D01_D
#
--format=dlang
_D9223372036854775817