Skip to content

Improvements based on SAST null reference reports#8895

Merged
headius merged 6 commits intojruby:masterfrom
headius:npe_reports
Jul 7, 2025
Merged

Improvements based on SAST null reference reports#8895
headius merged 6 commits intojruby:masterfrom
headius:npe_reports

Conversation

@headius
Copy link
Member

@headius headius commented Jul 7, 2025

The handful of NPE issues found by the SAST tool in #8840 are worth a look, so I'm fixing them here.

headius added 2 commits July 7, 2025 14:34
All callers pass in a non-null Encoding array, so let's make this
invariant and avoid any external callers.

Part of fixes for jruby#8840.
The null check here appears to be intended in the CRuby code to
check whether the given encoding name has already been set, and
return true if the new encoding would overwrite it. This is not
currently consumed by any code.

The switch to a lambda here avoids allocating the def_p out array.
The value originally put in that array is only used to set either
the default internal or default external encoding, which can be
done in a lambda.

Part of improvements for jruby#8840
@headius headius added this to the JRuby 10.0.1.0 milestone Jul 7, 2025
@headius headius marked this pull request as draft July 7, 2025 20:14
headius added 4 commits July 7, 2025 15:33
Both branches of the CFG null check below required the CFG to be
non-null, the second via the call to fic.toStringInstrs. Since we
have not seen NPE here, the CFG appears to never be null in our
uses of this listener, so ensure that is true with a hard check
and remove the null path.

Part of fixes for jruby#8840
This buildProcess was supposed to have been removed in 61ac7f3
but appears to have been missed. This case is especially bad
because it would lead to the process being launched twice.

Part of fixes for jruby#8840
@headius headius marked this pull request as ready for review July 7, 2025 21:36
@headius headius linked an issue Jul 7, 2025 that may be closed by this pull request
@headius headius merged commit ebb7075 into jruby:master Jul 7, 2025
142 of 143 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible bugs found by SAST (Svace)

1 participant