Closed as not planned
Closed as not planned
Description
Our SAST shows possible NullPointerException
or redundant null check inpublic class StartupInterpreterEngine extends InterpreterEngine {
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self,
InterpreterContext interpreterContext, RubyModule implClass,
String name, IRubyObject[] args, Block blockArg) {
...
int[] rescuePCs = interpreterContext.getRescueIPCs();
...
while (ipc < n) {
Instr instr = instrs[ipc];
Operation operation = instr.getOperation();
if (debug) {
Interpreter.LOG.info("I: " + ipc + ", R: " + rescuePCs[ipc] + " - " + instr + ">");
Interpreter.interpInstrsCount++;
} else if (profile) {
Profiler.instrTick(operation);
Interpreter.interpInstrsCount++;
}
try {
...
} catch (Throwable t) {
if (debug) extractToMethodToAvoidC2Crash(instr, t);
ipc = rescuePCs == null ? -1 : rescuePCs[ipc];
if (debug) {
Interpreter.LOG.info("in : " + interpreterContext.getScope() + ", caught Java throwable: " + t + "; excepting instr: " + instr);
Interpreter.LOG.info("ipc for rescuer: " + ipc);
}
if (ipc == -1) {
Helpers.throwException(t);
} else {
exception = t;
}
}
}
...
If rescuePCs can be null, then NPE will be thrown, if rescuePCs can't be null, then null comparison is redundant.
Environment Information
We are analyzing versions 9.4.x (8-12), but this problem is still in master
Expected Behavior
- No NPE at all. But it seems nobody catch it through the years, so i don't know if rescuePCs can be null at all
Actual Behavior
- have no tests to show this NPE, can't figure out how to make one. This is simply code analysis, that showed possible NPE
Metadata
Metadata
Assignees
Labels
No labels