aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-03-11 11:35:15 +0100
committerNikita Popov <npopov@redhat.com>2022-03-11 11:37:29 +0100
commit36be8fabb09764a080e69d37558dd8aa7b81526e (patch)
tree42250d32e9df577b33cb531dc4aea255c22e3d19 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parentba3380026aff2a1738c19c739fe04e1caf5964bf (diff)
downloadllvm-36be8fabb09764a080e69d37558dd8aa7b81526e.zip
llvm-36be8fabb09764a080e69d37558dd8aa7b81526e.tar.gz
llvm-36be8fabb09764a080e69d37558dd8aa7b81526e.tar.bz2
[Bitcode] Delete phi node on error
These error conditions are checked after the phi node has been created, so we also need to delete it.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 59e2ae9..767b5f5 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -5197,8 +5197,10 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
// floating-point type.
size_t NumArgs = (Record.size() - 1) / 2;
PHINode *PN = PHINode::Create(Ty, NumArgs);
- if ((Record.size() - 1) % 2 == 1 && !isa<FPMathOperator>(PN))
+ if ((Record.size() - 1) % 2 == 1 && !isa<FPMathOperator>(PN)) {
+ PN->deleteValue();
return error("Invalid phi record");
+ }
InstructionList.push_back(PN);
for (unsigned i = 0; i != NumArgs; i++) {
@@ -5211,8 +5213,10 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
else
V = getValue(Record, i * 2 + 1, NextValueNo, Ty, TyID);
BasicBlock *BB = getBasicBlock(Record[i * 2 + 2]);
- if (!V || !BB)
+ if (!V || !BB) {
+ PN->deleteValue();
return error("Invalid phi record");
+ }
PN->addIncoming(V, BB);
}
I = PN;