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

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 formatting. 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 023a433119266995c2ba026c305db89d07112148..f31f78a0f92bb1ac19de27e316c9141c5c1e3da2 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -1298,16 +1298,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;
}
@@ -2004,8 +2002,18 @@ private:
Ice::Variable *Var = getNextInstVar(Ty);
CurrentNode->appendInst(Ice::InstAssign::create(Func.get(), Var, Var));
}
+
+ Ice::Operand *reportGetOperandUndefined(NaClBcIndexSize_t Index);
Jim Stichnoth 2015/09/16 19:57:41 Seems a little odd not to just provide the definit
Karl 2015/09/16 20:47:29 Done.
};
+Ice::Operand *
+FunctionParser::reportGetOperandUndefined(NaClBcIndexSize_t Index) {
+ std::string Buffer;
+ raw_string_ostream StrBuf(Buffer);
+ StrBuf << "Value index " << Index << " not defined!";
+ Fatal(StrBuf.str());
+}
+
void FunctionParser::ExitBlock() {
// Check if the last instruction in the function was terminating.
if (!InstIsTerminating) {
« 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