This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH 3/7] Fix trinary op
- From: Mikhail Maltsev <maltsevm at gmail dot com>
- To: gcc-patches <gcc-patches at gnu dot org>, Jason Merrill <jason at redhat dot com>
- Date: Mon, 06 Jul 2015 22:34:36 +0300
- Subject: [PATCH 3/7] Fix trinary op
- Authentication-results: sourceware.org; auth=none
- References: <559AD66D dot 1070809 at gmail dot com>
---
libiberty/cp-demangle.c | 4 +++-
libiberty/testsuite/demangle-expected | 6 ++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 12093cc..44a0a9b 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -3267,7 +3267,9 @@ d_expression_1 (struct d_info *di)
struct demangle_component *second;
struct demangle_component *third;
- if (!strcmp (code, "qu"))
+ if (code == NULL)
+ return NULL;
+ else if (!strcmp (code, "qu"))
{
/* ?: expression. */
first = d_expression_1 (di);
diff --git a/libiberty/testsuite/demangle-expected
b/libiberty/testsuite/demangle-expected
index 6ea64ae..47ca8f5 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -4091,6 +4091,12 @@ void g<1>(A<1>&, B<static_cast<bool>(1)>&)
_ZNKSt7complexIiE4realB5cxx11Ev
std::complex<int>::real[abi:cxx11]() const
#
+# Some more crashes revealed by fuzz-testing:
+# Check for NULL pointer when demangling trinary operators
+--format=gnu-v3
+Av32_f
+Av32_f
+#
# Ada (GNAT) tests.
#
# Simple test.
--
1.8.3.1