[PATCH] D60963: Fix dereferencing null pointer

Mikhail Senkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 05:28:53 PDT 2019


zloyrobot created this revision.
zloyrobot added reviewers: amccarth, thakis.
zloyrobot added a project: LLDB.
Herald added subscribers: llvm-commits, lldb-commits, erik.pilkington, hiraditya.
Herald added a project: LLVM.

All callers of Demangler::parseTagUniqueName check 'Demangler.Error' and assume that 'Error is false' means 'return value is not null'


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D60963

Files:
  llvm/lib/Demangle/MicrosoftDemangle.cpp


Index: llvm/lib/Demangle/MicrosoftDemangle.cpp
===================================================================
--- llvm/lib/Demangle/MicrosoftDemangle.cpp
+++ llvm/lib/Demangle/MicrosoftDemangle.cpp
@@ -735,11 +735,15 @@
 }
 
 TagTypeNode *Demangler::parseTagUniqueName(StringView &MangledName) {
-  if (!MangledName.consumeFront(".?A"))
+  if (!MangledName.consumeFront(".?A")) {
+    Error = true;
     return nullptr;
+  }
   MangledName.consumeFront(".?A");
-  if (MangledName.empty())
+  if (MangledName.empty()) {
+    Error = true;
     return nullptr;
+  }
 
   return demangleClassType(MangledName);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60963.196057.patch
Type: text/x-patch
Size: 616 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190422/3e05e7ab/attachment.bin>


More information about the llvm-commits mailing list