[gcc r12-3865] libiberty: prevent null dereferencing on dlang_type
Jeff Law
law@gcc.gnu.org
Thu Sep 23 15:54:51 GMT 2021
https://gcc.gnu.org/g:b3585c0836e729bed56b9afd4292177673a25ca0
commit r12-3865-gb3585c0836e729bed56b9afd4292177673a25ca0
Author: Luís Ferreira <contact@lsferreira.net>
Date: Thu Sep 23 11:54:00 2021 -0400
libiberty: prevent null dereferencing on dlang_type
libiberty/
* d-demangle.c (dlang_Type): Validate MANGLED is nonnull.
* testsuite/d-demangle-expected: New test.
Diff:
---
libiberty/d-demangle.c | 2 +-
libiberty/testsuite/d-demangle-expected | 5 ++++-
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
#
More information about the Gcc-cvs
mailing list