Bug fix 15261: Wrong default inserted in struct
[scilab.git] / scilab / modules / ast / src / cpp / types / arrayof.cpp
index a6a1df5..c6955b1 100644 (file)
@@ -1641,12 +1641,17 @@ ArrayOf<T>* ArrayOf<T>::resize(int* _piDims, int _iDims)
                 int iNewIdx = getIndexWithDims(piIndexes, _piDims, _iDims);
                 pRealData[iNewIdx] = m_pRealData[i];
                 m_pRealData[i] = NULL;
-                T pTemp = getNullValue();
+
                 for (int j = iPreviousNewIdx; j < iNewIdx; ++j)
                 {
-                    pRealData[j] = copyValue(pTemp);
+                    T pTemp = getNullValue();
+                    T pTemp2 = copyValue(pTemp);
+                    pRealData[j] = pTemp2;
+                    if (pTemp != pTemp2)
+                    {
+                        deleteData(pTemp);
+                    }
                 }
-                deleteData(pTemp);
 
                 iPreviousNewIdx = iNewIdx + 1;
             }
@@ -1672,12 +1677,16 @@ ArrayOf<T>* ArrayOf<T>::resize(int* _piDims, int _iDims)
             //}
 
             //fill exceeded with NullValue
-            T pTemp = getNullValue();
             for (int i = iPreviousNewIdx; i < m_iSizeMax; ++i)
             {
-                pRealData[i] = copyValue(pTemp);
+                T pTemp = getNullValue();
+                T pTemp2 = copyValue(pTemp);
+                pRealData[i] = pTemp2;
+                if (pTemp != pTemp2)
+                {
+                    deleteData(pTemp);
+                }
             }
-            deleteData(pTemp);
 
             delete[] piIndexes;
             //delete all array