Skip to content

Commit

Permalink
NULL ptr field _postDominators to avoid scope issues in future
Browse files Browse the repository at this point in the history
Pointer field `_postDominator` gets initialized to a local variable.
As of right now all access points of the variable are guarded by NULL
checks. Setting it to NULL before we exit the method to avoid bugs which
may arise from accidental use of the variable without a NULL check.

Signed-off-by: Shubham Verma <shubhamv.sv@gmail.com>
  • Loading branch information
VermaSh committed Nov 18, 2020
1 parent cb2c463 commit b69fb82
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion compiler/optimizer/LoopVersioner.cpp
Expand Up @@ -192,8 +192,15 @@ int32_t TR_LoopVersioner::performWithDominators()
{
printf("WARNING: method may have infinite loops\n");
}
auto result = performWithoutDominators();

return performWithoutDominators();
/* Local variable postDominators is about to go out of scope.
* NULL this field to prevent illegal access to a stack
* allocated object.
*/
_postDominators = NULL;

return result;
}


Expand Down

0 comments on commit b69fb82

Please sign in to comment.