Coverity: External_objects_java module memory errors fixed 06/18306/2
Dhruv Khattar [Sat, 25 Jun 2016 21:11:37 +0000 (02:11 +0530)]
Change-Id: I885317a9225034cdf1bc820c8f84788dd80c4541

scilab/modules/external_objects_java/sci_gateway/cpp/sci_jcreatejar.cpp
scilab/modules/external_objects_java/src/cpp/ScilabJavaEnvironmentWrapper.hxx

index 6c2f954..23cd5cc 100644 (file)
@@ -132,6 +132,10 @@ int sci_jcreatejar(char *fname, void* pvApiCtx)
             if (sciErr.iErr)
             {
                 printError(&sciErr, 0);
+                freeAllocatedSingleString(jarFilePath);
+                freeAllocatedMatrixOfString(nbRow, nbCol, filePaths);
+                freeAllocatedSingleString(filesRootPath);
+                freeAllocatedSingleString(manifestFilePath);
                 return 1;
             }
             ret[0] = (res == 0) ? 1 : 0;
index 6381a15..71c6832 100644 (file)
@@ -394,9 +394,9 @@ private:
             T ** xx = new T*[c];
             int i;
             xx[0] = x;
-            for (i = 1; i < c; xx[i] = xx[i++ - 1] + r)
+            for (i = 1; i < c; i++)
             {
-                ;
+                xx[i] = xx[i - 1] + r;
             }
             i = ScilabJavaObject::wrap(vm, xx, c, r);
             delete[] xx;