[matelm] invalid read and mismatch free fixed 75/18775/2
Cedric Delamarre [Thu, 8 Dec 2016 13:36:00 +0000 (14:36 +0100)]
  test_run core matelm mode_nwni_profiling
  test_run elementary_functions cumsum mode_nwni_profiling
  test_run elementary_functions cumprod mode_nwni_profiling

Change-Id: I137e13ed62051d8e7e8a6b750b6c1f4aa22347ca

scilab/modules/ast/src/cpp/types/double.cpp
scilab/modules/elementary_functions/sci_gateway/cpp/sci_cumprod.cpp
scilab/modules/elementary_functions/sci_gateway/cpp/sci_cumsum.cpp

index ecbc7ce..e57ba36 100644 (file)
@@ -933,7 +933,15 @@ double Double::copyValue(double _dblData)
 
 void Double::deleteAll()
 {
-    delete[] m_pRealData;
+    if (isViewAsZComplex())
+    {
+        vFreeDoubleComplexFromPointer((doublecomplex*)m_pRealData);
+    }
+    else
+    {
+        delete[] m_pRealData;
+    }
+
     m_pRealData = NULL;
     deleteImg();
 }
index 85576b9..fcba87e 100644 (file)
@@ -55,6 +55,12 @@ types::Function::ReturnValue sci_cumprod(types::typed_list &in, int _iRetCount,
         return types::Function::Error;
     }
 
+    if (in[0]->isDouble() && in[0]->getAs<types::Double>()->isEmpty())
+    {
+        out.push_back(types::Double::Empty());
+        return types::Function::OK;
+    }
+
     bool isCloned = true;
     /***** get data *****/
     switch (in[0]->getType())
index 809bff7..ad5b0c3 100644 (file)
@@ -54,6 +54,12 @@ types::Function::ReturnValue sci_cumsum(types::typed_list &in, int _iRetCount, t
         return types::Function::Error;
     }
 
+    if (in[0]->isDouble() && in[0]->getAs<types::Double>()->isEmpty())
+    {
+        out.push_back(types::Double::Empty());
+        return types::Function::OK;
+    }
+
     bool isCloned = true;
     /***** get data *****/
     switch (in[0]->getType())