Coverity #1099169, #1320913, #1321304 fixed 33/18433/4
Dhruv Khattar [Tue, 9 Aug 2016 17:31:53 +0000 (22:31 +0530)]
Change-Id: I1646c9c3b52d18c459bfad5a37b800d06878306e

scilab/modules/scicos_blocks/src/c/cscopxy3d.c
scilab/modules/scicos_blocks/src/cpp/fromws_c.cpp

index 40451c1..70d0673 100644 (file)
@@ -344,15 +344,21 @@ error_handler:
 static void appendData(scicos_block * block, double *x, double *y, double *z)
 {
     int i;
+    int maxNumberOfPoints;
+    int numberOfPoints;
 
     sco_data *sco = (sco_data *) * (block->work);
-    int maxNumberOfPoints = sco->internal.maxNumberOfPoints;
-    int numberOfPoints = sco->internal.numberOfPoints;
+    if (sco == NULL)
+    {
+        return;
+    }
+    maxNumberOfPoints = sco->internal.maxNumberOfPoints;
+    numberOfPoints = sco->internal.numberOfPoints;
 
     /*
      * Handle the case where the scope has more points than maxNumberOfPoints
      */
-    if (sco != NULL && numberOfPoints >= maxNumberOfPoints)
+    if (numberOfPoints >= maxNumberOfPoints)
     {
         // on a full scope, re-alloc
         maxNumberOfPoints = maxNumberOfPoints + block->ipar[2];
index 235fb57..347e1b7 100644 (file)
@@ -410,6 +410,7 @@ SCICOS_BLOCKS_IMPEXP void fromws_c(scicos_block* block, int flag)
                 *work = nullptr;
                 delete[] (char*) ptr->work;
                 delete[] ptr;
+                delete[] ptDims;
                 closeHDF5File(fd);
                 return;
             }
@@ -420,6 +421,7 @@ SCICOS_BLOCKS_IMPEXP void fromws_c(scicos_block* block, int flag)
                 *work = nullptr;
                 delete[] (char*) ptr->work;
                 delete[] ptr;
+                delete[] ptDims;
                 closeHDF5File(fd);
                 return;
             }
@@ -435,6 +437,7 @@ SCICOS_BLOCKS_IMPEXP void fromws_c(scicos_block* block, int flag)
                 delete[] (char*) ptr->work;
                 delete[] ptr;
                 closeHDF5File(fd);
+                return;
             }
 
             /* Close the file */