-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
Our SAST shows possible NullPointerException in https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/RubyModule.java#L2103
private CacheEntry searchWithCacheMiss(Ruby runtime, final String id, final boolean cacheUndef) {
final int token = generation;
CacheEntry methodEntry = searchMethodEntryInner(id);
if (methodEntry == null) {
if (cacheUndef) {
return addToCache(id, UndefinedMethod.getInstance(), this, token);
}
return cacheEntryFactory.newCacheEntry(id, UndefinedMethod.getInstance(), methodEntry.sourceModule, token);
} else if (!runtime.isBooting()) {
addToCache(id, methodEntry);
}
return methodEntry;
}
If methodEntry is null, then dereference of sourceModule will cause NPE.
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 this code is reachable at all
Actual Behavior
- I have no tests to show this NPE, can't figure out how to make one. This is simply code analysis, that showed possible NPE
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels