[PATCH] D157470: [NFC]Add assert to avoid deref nullptr
Wang, Xin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 8 20:08:07 PDT 2023
XinWang10 created this revision.
Herald added a project: All.
XinWang10 requested review of this revision.
Herald added subscribers: llvm-commits, wangpc.
Herald added a project: LLVM.
Static analyzer reports dyn_cast at line 970 could return nullptr which could lead to security issue when deref it at line 971.
I think author could confirm the ptr Code could always be StringInit type here so I add assert to avoid static analyzer report.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157470
Files:
llvm/utils/TableGen/GlobalISelCombinerMatchTableEmitter.cpp
Index: llvm/utils/TableGen/GlobalISelCombinerMatchTableEmitter.cpp
===================================================================
--- llvm/utils/TableGen/GlobalISelCombinerMatchTableEmitter.cpp
+++ llvm/utils/TableGen/GlobalISelCombinerMatchTableEmitter.cpp
@@ -968,6 +968,7 @@
}
const StringInit *Code = dyn_cast<StringInit>(Apply.getArg(0));
+ assert(Code && "Expected 1 StringInit argument in 'apply'");
auto Pat = std::make_unique<CXXPattern>(*Code, makeAnonPatName("apply"),
/*IsApply*/ true);
ApplyPats[Pat->getName()] = std::move(Pat);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157470.548447.patch
Type: text/x-patch
Size: 606 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230809/af7e7f1d/attachment.bin>
More information about the llvm-commits
mailing list