Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1149

unsafe initialization in DummyStepInterpolator

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.3
    • Fix Version/s: 3.4
    • Labels:
      None

      Description

      DummyStepInterpolator.java
        public DummyStepInterpolator(final DummyStepInterpolator interpolator) {
          super(interpolator);
          currentDerivative = interpolator.currentDerivative.clone();
        }
         @Override
        protected StepInterpolator doCopy() {
          return new DummyStepInterpolator(this);
        }
      

      A constructor in DummyStepInterpolator dereferences a field of the parameter, but a NullPointerException can occur during a call to doCopy().

      Test.java
      public void test1() throws Throwable {
        DummyStepInterpolator var0 = new DummyStepInterpolator();
        var0.copy();
      }
      

      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.

      NordsieckStepInterpolator.java
          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);
          }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mjkim0324 M Kim
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: