Coverity #1353544, #1353546 fixed 27/18227/1
Dhruv Khattar [Tue, 7 Jun 2016 07:26:21 +0000 (12:26 +0530)]
Change-Id: I9d8f42e14f9a72cd32e5f3c232acd2ca94a32f74

scilab/modules/time/sci_gateway/c/sci_sleep.c

index 33cb0ec..aa94dbf 100644 (file)
@@ -62,17 +62,22 @@ int sci_sleep(char *fname, void* pvApiCtx)
         if (Rhs == 2)
         {
             sciErr = getVarAddressFromPosition(pvApiCtx, 2, &p2_in_address);
-            getAllocatedSingleString(pvApiCtx, p2_in_address, &opt);
+            if (getAllocatedSingleString(pvApiCtx, p2_in_address, &opt))
+            {
+                return 0;
+            }
 
             if (strcmp("s", opt) != 0)
             {
                 Scierror(999, _("%s: Wrong value for input argument #%d: 's' expected.\n"), fname, 2);
+                freeAllocatedSingleString(opt);
                 return 0;
             }
             if (strcmp("s", opt) == 0)
             {
                 option = 1;
             }
+            freeAllocatedSingleString(opt);
         }