Coverity #1099079, #1099546, #1194641, #1354289, #1099315 fixed 36/18436/3
Dhruv Khattar [Wed, 10 Aug 2016 04:40:08 +0000 (09:40 +0530)]
Change-Id: Idf1f2badd670e89c1d0dc48edaff5cd21388e053

scilab/modules/gui/sci_gateway/c/sci_figure.c
scilab/modules/gui/sci_gateway/c/sci_toolbar.c
scilab/modules/gui/sci_gateway/c/sci_x_mdialog.c
scilab/modules/gui/sci_gateway/cpp/sci_uigetfont.cpp
scilab/modules/gui/sci_gateway/cpp/sci_usecanvas.cpp

index 724b5d0..8f8a08b 100644 (file)
@@ -233,6 +233,7 @@ int sci_figure(char * fname, void* pvApiCtx)
                 {
                     Scierror(999, _("%s: Wrong size for input argument #%d: A single string expected.\n"), fname, i);
                     freeAllocatedSingleString(pstProName);
+                    return 1;
                 }
 
                 if (getAllocatedSingleString(pvApiCtx, piAddrData, &pstVal))
index 192bb40..5dd2a9c 100644 (file)
@@ -223,11 +223,8 @@ int sci_toolbar(char *fname, void* pvApiCtx)
 
     AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1;
 
-    if (Output)
-    {
-        FREE(Output);
-        Output = NULL;
-    }
+    FREE(Output);
+    Output = NULL;
 
     ReturnArguments(pvApiCtx);
     return TRUE;
index ea12c7d..b8e07bd 100644 (file)
@@ -140,12 +140,6 @@ int sci_x_mdialog(char *fname, void* pvApiCtx)
                 return FALSE;
             }
 
-            if (nbRowDefaultValues != 1 && nbColDefaultValues != 1)
-            {
-                freeAllocatedMatrixOfString(nbRowDefaultValues, nbColDefaultValues, defaultValuesAdr);
-                Scierror(999, _("%s: Wrong size for input argument #%d: Vector of strings expected.\n"), fname, 3);
-                return FALSE;
-            }
             setMessageBoxDefaultInput(messageBoxID, defaultValuesAdr, nbColDefaultValues * nbRowDefaultValues);
             freeAllocatedMatrixOfString(nbRowDefaultValues, nbColDefaultValues, defaultValuesAdr);
         }
index 439de06..46cfed9 100644 (file)
@@ -252,10 +252,7 @@ int sci_uigetfont(char *fname, void* pvApiCtx)
             }
         }
 
-        if (selectedFontName)
-        {
-            freeAllocatedSingleString(selectedFontName);
-        }
+        delete[] selectedFontName;
 
         if (nbOutputArgument(pvApiCtx) >= 2)
         {
@@ -298,10 +295,7 @@ int sci_uigetfont(char *fname, void* pvApiCtx)
     }
     else /* The user canceled */
     {
-        if (selectedFontName)
-        {
-            freeAllocatedSingleString(selectedFontName);
-        }
+        delete[] selectedFontName;
         nbRow = 0;
         nbCol = 0;
         if (nbOutputArgument(pvApiCtx) >= 1)
index 0bbb4a9..c53162f 100644 (file)
@@ -86,7 +86,7 @@ int sci_usecanvas(char *fname, void* pvApiCtx)
 
     if (createScalarDouble(pvApiCtx, 1, status))
     {
-        printError(&sciErr, 0);
+        Scierror(999, _("%s: Memory allocation error.\n"), fname);
         return 1;
     }