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

Unified Diff: src/PNaClTranslator.cpp

Issue 1346723002: Fix operand lookup in functions to check if local index out of range. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nit in last patch. Created 5 years, 3 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 | tests_lit/parse_errs/Inputs/fcn-value-index-isnt-defined.tbc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/PNaClTranslator.cpp
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index d8d1860f1ef760bf1ac5bda1b21f5cb964562d9e..d3c71fd4091cb737d4bbe45f4347fac86b0cfba6 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -1283,16 +1283,14 @@ public:
if (Index < CachedNumGlobalValueIDs) {
return Context->getGlobalConstantByID(Index);
}
+ if (isIRGenerationDisabled())
+ return nullptr;
NaClBcIndexSize_t LocalIndex = Index - CachedNumGlobalValueIDs;
+ if (LocalIndex >= LocalOperands.size())
+ reportGetOperandUndefined(Index);
Ice::Operand *Op = LocalOperands[LocalIndex];
- if (Op == nullptr) {
- if (isIRGenerationDisabled())
- return nullptr;
- std::string Buffer;
- raw_string_ostream StrBuf(Buffer);
- StrBuf << "Value index " << Index << " not defined!";
- Fatal(StrBuf.str());
- }
+ if (Op == nullptr)
+ reportGetOperandUndefined(Index);
return Op;
}
@@ -1981,6 +1979,13 @@ private:
Ice::Variable *Var = getNextInstVar(Ty);
CurrentNode->appendInst(Ice::InstAssign::create(Func.get(), Var, Var));
}
+
+ Ice::Operand *reportGetOperandUndefined(NaClBcIndexSize_t Index) {
+ std::string Buffer;
+ raw_string_ostream StrBuf(Buffer);
+ StrBuf << "Value index " << Index << " not defined!";
+ Fatal(StrBuf.str());
+ }
};
void FunctionParser::ExitBlock() {
« no previous file with comments | « no previous file | tests_lit/parse_errs/Inputs/fcn-value-index-isnt-defined.tbc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698