You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Thomas Neidhart (JIRA)" <ji...@apache.org> on 2014/09/13 17:37:34 UTC
[jira] [Resolved] (MATH-1149) unsafe initialization in
DummyStepInterpolator
[ https://issues.apache.org/jira/browse/MATH-1149?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Neidhart resolved MATH-1149.
-----------------------------------
Resolution: Fixed
Fix Version/s: 3.4
Fixed in r1624752.
Thanks for the report!
> unsafe initialization in DummyStepInterpolator
> ----------------------------------------------
>
> Key: MATH-1149
> URL: https://issues.apache.org/jira/browse/MATH-1149
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 3.3
> Reporter: M Kim
> Fix For: 3.4
>
>
> {code:title=DummyStepInterpolator.java|borderStyle=solid}
> public DummyStepInterpolator(final DummyStepInterpolator interpolator) {
> super(interpolator);
> currentDerivative = interpolator.currentDerivative.clone();
> }
> @Override
> protected StepInterpolator doCopy() {
> return new DummyStepInterpolator(this);
> }
> {code}
> A constructor in DummyStepInterpolator dereferences a field of the parameter, but a NullPointerException can occur during a call to doCopy().
> {code:title=Test.java|borderStyle=solid}
> public void test1() throws Throwable {
> DummyStepInterpolator var0 = new DummyStepInterpolator();
> var0.copy();
> }
> {code}
> Here in Test.java, a NPE occurs because copy() calls doCopy() which calls DummyStepInterpolator(final DummyStepInterpolator) that passes var0 as an argument.
> I think this constructor should have a null check for interpolator.currentDerivative like NordsieckStepInterpolator does.
> {code:title=NordsieckStepInterpolator.java|borderStyle=solid}
> public NordsieckStepInterpolator(final NordsieckStepInterpolator interpolator) {
> super(interpolator);
> scalingH = interpolator.scalingH;
> referenceTime = interpolator.referenceTime;
> if (interpolator.scaled != null) {
> scaled = interpolator.scaled.clone();
> }
> if (interpolator.nordsieck != null) {
> nordsieck = new Array2DRowRealMatrix(interpolator.nordsieck.getDataRef(), true);
> }
> if (interpolator.stateVariation != null) {
> stateVariation = interpolator.stateVariation.clone();
> }
> }
> @Override
> protected StepInterpolator doCopy() {
> return new NordsieckStepInterpolator(this);
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)