[llvm] 6f5ecd0 - Demangle: Fix crash-on-invalid demangling of a module name with no underlying entity
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 30 13:26:41 PDT 2022
Author: David Blaikie
Date: 2022-03-30T20:26:32Z
New Revision: 6f5ecd089f77e0da9af44bb7211ad1b11ea582d4
URL: https://github.com/llvm/llvm-project/commit/6f5ecd089f77e0da9af44bb7211ad1b11ea582d4
DIFF: https://github.com/llvm/llvm-project/commit/6f5ecd089f77e0da9af44bb7211ad1b11ea582d4.diff
LOG: Demangle: Fix crash-on-invalid demangling of a module name with no underlying entity
Added:
Modified:
libcxxabi/src/demangle/ItaniumDemangle.h
libcxxabi/test/test_demangle.pass.cpp
llvm/include/llvm/Demangle/ItaniumDemangle.h
Removed:
################################################################################
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index be2cf882bfc22..a434868ce1a52 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -2885,7 +2885,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseUnqualifiedName(
Result = getDerived().parseOperatorName(State);
}
- if (Module)
+ if (Result != nullptr && Module != nullptr)
Result = make<ModuleEntity>(Module, Result);
if (Result != nullptr)
Result = getDerived().parseAbiTags(Result);
diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index a0d9bad298b1a..916fda6a929de 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -30172,6 +30172,7 @@ const char* invalid_cases[] =
"_ZWDC3FOOEv",
"_ZGI3Foo",
"_ZGIW3Foov",
+ "W1x",
};
const unsigned NI = sizeof(invalid_cases) / sizeof(invalid_cases[0]);
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 778342e7fd594..f933e9a3262d5 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -2885,7 +2885,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseUnqualifiedName(
Result = getDerived().parseOperatorName(State);
}
- if (Module)
+ if (Result != nullptr && Module != nullptr)
Result = make<ModuleEntity>(Module, Result);
if (Result != nullptr)
Result = getDerived().parseAbiTags(Result);
More information about the llvm-commits
mailing list