Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Unified Diff: lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp

Issue 1283353002: Fix handling errors in switch instruction by PNaCl bitcode reader. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/NaCl/Bitcode/pnacl-bcdis/Inputs/bad-switch-case.tbc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
index 4bfe85ce6d13a672da0b022d61087166c6ab2d72..f555f9d8d49f4aff911af3cde3ea4fe302f49b85 100644
--- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
+++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
@@ -1510,13 +1510,19 @@ std::error_code NaClBitcodeReader::ParseFunctionBody(Function *F) {
"Incomplete case entry in SWITCH record");
uint64_t NumItems = Record[CurIdx++];
bool isSingleNumber = Record[CurIdx++];
- if (NumItems != 1 || !isSingleNumber)
+ if (NumItems != 1 || !isSingleNumber) {
+ delete SI;
JF 2015/08/18 17:07:46 Can this file as well as upstream lib/Bitcode/Read
Karl 2015/08/19 19:39:00 Switches are not special. The code was written thi
return Error(InvalidRecord,
"Case ranges are not supported in PNaCl bitcode");
+ }
APInt CaseValue(ValueBitWidth,
NaClDecodeSignRotatedValue(Record[CurIdx++]));
BasicBlock *DestBB = getBasicBlock(Record[CurIdx++]);
+ if (DestBB == nullptr) {
+ delete SI;
+ return Error(InvalidValue, "Invalid branch in SWITCH case");
+ }
SI->addCase(ConstantInt::get(Context, CaseValue), DestBB);
}
I = SI;
« no previous file with comments | « no previous file | test/NaCl/Bitcode/pnacl-bcdis/Inputs/bad-switch-case.tbc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698