Commit 1a4b1b3c by Jamie Madill

Fix use-after-delete in ParseContext.cpp.

This bug was exposed after a refactoring from the translator. BUG=None TEST=angle_unittests,angle_end2end_tests Change-Id: I13fddcbe84f87826068a557f139f6e35c674571e Reviewed-on: https://chromium-review.googlesource.com/287832Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 73a5b648
...@@ -930,8 +930,7 @@ bool TParseContext::declareVariable(const TSourceLoc &line, const TString &ident ...@@ -930,8 +930,7 @@ bool TParseContext::declareVariable(const TSourceLoc &line, const TString &ident
if (!symbolTable.declare(*variable)) if (!symbolTable.declare(*variable))
{ {
error(line, "redefinition", identifier.c_str()); error(line, "redefinition", identifier.c_str());
delete (*variable); *variable = nullptr;
(*variable) = nullptr;
return false; return false;
} }
...@@ -1884,10 +1883,13 @@ void TParseContext::parseFunctionPrototype(const TSourceLoc &location, ...@@ -1884,10 +1883,13 @@ void TParseContext::parseFunctionPrototype(const TSourceLoc &location,
// //
// Insert the parameters with name in the symbol table. // Insert the parameters with name in the symbol table.
// //
if (!symbolTable.declare(variable)) { if (!symbolTable.declare(variable))
{
error(location, "redefinition", variable->getName().c_str()); error(location, "redefinition", variable->getName().c_str());
recover(); recover();
delete variable; paramNodes = intermediate.growAggregate(
paramNodes, intermediate.addSymbol(0, "", *param.type, location), location);
continue;
} }
// //
...@@ -3758,7 +3760,6 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN ...@@ -3758,7 +3760,6 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall, TIntermN
recover(); recover();
} }
} }
delete fnCall;
return callNode; return callNode;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment