summaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorLuís Ferreira <contact@lsferreira.net>2021-09-23 11:54:00 -0400
committerJeff Law <jeffreyalaw@gmail.com>2021-09-23 11:54:00 -0400
commitb3585c0836e729bed56b9afd4292177673a25ca0 (patch)
treec0df980cedac78eca6069c9ccb657abdc4565f03 /libiberty
parent5481040197402be6dfee265bd2ff5a4c88e30505 (diff)
downloadgcc-b3585c0836e729bed56b9afd4292177673a25ca0.tar.gz
libiberty: prevent null dereferencing on dlang_type
libiberty/ * d-demangle.c (dlang_Type): Validate MANGLED is nonnull. * testsuite/d-demangle-expected: New test.
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/d-demangle.c2
-rw-r--r--libiberty/testsuite/d-demangle-expected5
2 files changed, 5 insertions, 2 deletions
diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 7ded3e2a256..3adf7b562d1 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -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);
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index c35185c3e1e..799f4724b72 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -991,11 +991,14 @@ _D88
_D5__T1aZv
_D5__T1aZv
#
---format=dlang
_D00
_D00
#
--format=dlang
+_D01_D
+_D01_D
+#
+--format=dlang
_D9223372036854775817
_D9223372036854775817
#