[Kst] extragear/graphics/kst/src/plugins/correlation/autocorrelation

Adam Treat treat at kde.org
Wed Dec 6 18:32:06 CET 2006


SVN commit 611099 by treat:

* This was crashing on exit whenever this plugin was used. The algorithm,
for some unexplained reason, was trying to access an input that does not
exist.  This caused an invalid access of the input arrays. 



 M  +12 -12    autocorrelate.cpp  


--- trunk/extragear/graphics/kst/src/plugins/correlation/autocorrelation/autocorrelate.cpp #611098:611099
@@ -22,7 +22,8 @@
 		double outScalars[])
 {
   double* pdArrayOne;
-  double* pdResult[2];
+  double* pdResult;
+  double* pdCorrelate;
   double  dReal;
   double  dImag;
   int i = 0;
@@ -90,29 +91,29 @@
           {
             if( outArrayLens[0] != inArrayLens[0] )
             {
-              pdResult[0] = (double*)realloc( outArrays[0], inArrayLens[0] * sizeof( double ) );
+              pdResult = (double*)realloc( outArrays[0], inArrayLens[0] * sizeof( double ) );
             }
             else
             {
-              pdResult[0] = outArrays[0];
+              pdResult = outArrays[0];
             }
 
-            if( outArrayLens[1] != inArrayLens[1] )
+            if( outArrayLens[1] != inArrayLens[0] )
             {
-              pdResult[1] = (double*)realloc( outArrays[1], inArrayLens[1] * sizeof( double ) );
+              pdCorrelate = (double*)realloc( outArrays[1], inArrayLens[0] * sizeof( double ) );
             }
             else
             {
-              pdResult[1] = outArrays[1];
+              pdCorrelate = outArrays[1];
             }
 
-            if( pdResult[0] != NULL && pdResult[1] != NULL )
+            if( pdResult != NULL && pdCorrelate != NULL )
             {
-              outArrays[0] = pdResult[0];
+              outArrays[0] = pdResult;
               outArrayLens[0] = inArrayLens[0];
 
-              outArrays[1] = pdResult[1];
-              outArrayLens[1] = inArrayLens[1];
+              outArrays[1] = pdCorrelate;
+              outArrayLens[1] = inArrayLens[0];
 
               for( i=0; i<inArrayLens[0]; i++ )
               {
@@ -131,9 +132,8 @@
             }
           }
         }
-        
-        delete[] pdArrayOne;
       }
+      delete[] pdArrayOne;
     }
   }
   


More information about the Kst mailing list