Coverity #1165289,90,91,92,93,94,95,96,97,98,#1165304,05,06,07,09 Fixed 88/17988/7
Aashish Misraa [Sun, 27 Mar 2016 13:12:24 +0000 (18:12 +0530)]
Change-Id: I4fb82e243ab16056dc850d8f524730008ad0b9f6

scilab/modules/graphics/src/c/getHandleProperty/set_border_property.c

index a18e593..c0ae2cb 100644 (file)
@@ -98,47 +98,48 @@ int createBorder(void* _pvCtx, int* _piAddrList, int _iParent)
     }
 
     pstType = pstField[0];
-
+    int ret = 0; //empty uid
+    
     //depend of kind of tlist
     if (strcmp(pstType, "NoBorder") == 0)
     {
-        return clearBorder(_iParent);
+        ret = clearBorder(_iParent);
     }
     else if (strcmp(pstType, "LineBorder") == 0)
     {
-        return createLineBorder(_pvCtx, _piAddrList, _iParent);
+        ret = createLineBorder(_pvCtx, _piAddrList, _iParent);
     }
     else if (strcmp(pstType, "BevelBorder") == 0)
     {
-        return createBevelBorder(_pvCtx, _piAddrList, _iParent);
+        ret = createBevelBorder(_pvCtx, _piAddrList, _iParent);
     }
     else if (strcmp(pstType, "SoftBevelBorder") == 0)
     {
-        return createSoftBevelBorder(_pvCtx, _piAddrList, _iParent);
+        ret = createSoftBevelBorder(_pvCtx, _piAddrList, _iParent);
     }
     else if (strcmp(pstType, "EtchedBorder") == 0)
     {
-        return createEtchedBorder(_pvCtx, _piAddrList, _iParent);
+        ret = createEtchedBorder(_pvCtx, _piAddrList, _iParent);
     }
     else if (strcmp(pstType, "TitledBorder") == 0)
     {
-        return createTitledBorder(_pvCtx, _piAddrList, _iParent);
+        ret = createTitledBorder(_pvCtx, _piAddrList, _iParent);
     }
     else if (strcmp(pstType, "EmptyBorder") == 0)
     {
-        return createEmptyBorder(_pvCtx, _piAddrList, _iParent);
+        ret = createEmptyBorder(_pvCtx, _piAddrList, _iParent);
     }
     else if (strcmp(pstType, "CompoundBorder") == 0)
     {
-        return createCompoundBorder(_pvCtx, _piAddrList, _iParent);
+        ret = createCompoundBorder(_pvCtx, _piAddrList, _iParent);
     }
     else if (strcmp(pstType, "MatteBorder") == 0)
     {
-        return createMatteBorder(_pvCtx, _piAddrList, _iParent);
+        ret = createMatteBorder(_pvCtx, _piAddrList, _iParent);
     }
 
-    //empty uid
-    return 0;
+    freeAllocatedMatrixOfString(iRows, iCols, pstField);
+    return ret;
 }
 /*------------------------------------------------------------------------*/
 int clearBorder(int iObjUID)
@@ -208,11 +209,13 @@ int createLineBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
         sciErr = getListItemAddress(_pvCtx, _piAddrList, 3, &piAddr3);
         if (sciErr.iErr)
         {
+            freeAllocatedSingleString(pstColor);
             return SET_PROPERTY_ERROR;
         }
 
         if (getScalarDouble(_pvCtx, piAddr3, &dblThickness))
         {
+            freeAllocatedSingleString(pstColor);
             return SET_PROPERTY_ERROR;
         }
 
@@ -225,11 +228,13 @@ int createLineBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
         sciErr = getListItemAddress(_pvCtx, _piAddrList, 4, &piAddr4);
         if (sciErr.iErr)
         {
+            freeAllocatedSingleString(pstColor);
             return SET_PROPERTY_ERROR;
         }
 
         if (getScalarBoolean(_pvCtx, piAddr4, &bRounded))
         {
+            freeAllocatedSingleString(pstColor);
             return SET_PROPERTY_ERROR;
         }
     }
@@ -246,6 +251,7 @@ int createLineBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
     iBorder = createGraphicObject(__GO_UI_FRAME_BORDER__);
     if (iBorder == 0)
     {
+        freeAllocatedSingleString(pstColor);
         return SET_PROPERTY_ERROR;
     }
 
@@ -349,11 +355,13 @@ int createCommonBevelBorder(void* _pvCtx, int* _piAddrList, int _iObjUID, int _i
         sciErr = getListItemAddress(_pvCtx, _piAddrList, 4, &piAddr4);
         if (sciErr.iErr)
         {
+            freeAllocatedSingleString(pstHlOutColor);
             return SET_PROPERTY_ERROR;
         }
 
         if (getAllocatedSingleString(_pvCtx, piAddr4, &pstHlInColor))
         {
+            freeAllocatedSingleString(pstHlOutColor);
             return SET_PROPERTY_ERROR;
         }
     }
@@ -364,11 +372,15 @@ int createCommonBevelBorder(void* _pvCtx, int* _piAddrList, int _iObjUID, int _i
         sciErr = getListItemAddress(_pvCtx, _piAddrList, 5, &piAddr5);
         if (sciErr.iErr)
         {
+            freeAllocatedSingleString(pstHlInColor);
+            freeAllocatedSingleString(pstHlOutColor);
             return SET_PROPERTY_ERROR;
         }
 
         if (getAllocatedSingleString(_pvCtx, piAddr5, &pstShadowOutColor))
         {
+            freeAllocatedSingleString(pstHlInColor);
+            freeAllocatedSingleString(pstHlOutColor);
             return SET_PROPERTY_ERROR;
         }
 
@@ -376,11 +388,17 @@ int createCommonBevelBorder(void* _pvCtx, int* _piAddrList, int _iObjUID, int _i
         sciErr = getListItemAddress(_pvCtx, _piAddrList, 6, &piAddr6);
         if (sciErr.iErr)
         {
+            freeAllocatedSingleString(pstShadowOutColor);
+            freeAllocatedSingleString(pstHlInColor);
+            freeAllocatedSingleString(pstHlOutColor);
             return SET_PROPERTY_ERROR;
         }
 
         if (getAllocatedSingleString(_pvCtx, piAddr6, &pstShadowInColor))
         {
+            freeAllocatedSingleString(pstShadowOutColor);
+            freeAllocatedSingleString(pstHlInColor);
+            freeAllocatedSingleString(pstHlOutColor);
             return SET_PROPERTY_ERROR;
         }
     }
@@ -397,6 +415,10 @@ int createCommonBevelBorder(void* _pvCtx, int* _piAddrList, int _iObjUID, int _i
     iBorder = createGraphicObject(__GO_UI_FRAME_BORDER__);
     if (iBorder == 0)
     {
+        freeAllocatedSingleString(pstShadowInColor);
+        freeAllocatedSingleString(pstShadowOutColor);
+        freeAllocatedSingleString(pstHlInColor);
+        freeAllocatedSingleString(pstHlOutColor);
         return SET_PROPERTY_ERROR;
     }
 
@@ -505,6 +527,7 @@ int createEtchedBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
 
         if (getAllocatedSingleString(_pvCtx, piAddr4, &pstShadowOutColor))
         {
+            freeAllocatedSingleString(pstHlOutColor);
             return SET_PROPERTY_ERROR;
         }
     }
@@ -523,6 +546,8 @@ int createEtchedBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
     iBorder = createGraphicObject(__GO_UI_FRAME_BORDER__);
     if (iBorder == 0)
     {
+        freeAllocatedSingleString(pstShadowOutColor);
+        freeAllocatedSingleString(pstHlOutColor);
         return SET_PROPERTY_ERROR;
     }
 
@@ -626,11 +651,13 @@ int createTitledBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
         sciErr = getListItemAddress(_pvCtx, _piAddrList, 4, &piAddr4);
         if (sciErr.iErr)
         {
+            freeAllocatedSingleString(pstTitle);
             return SET_PROPERTY_ERROR;
         }
 
         if (getAllocatedSingleString(_pvCtx, piAddr4, &pstJustification))
         {
+            freeAllocatedSingleString(pstTitle);
             return SET_PROPERTY_ERROR;
         }
 
@@ -661,11 +688,13 @@ int createTitledBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
         sciErr = getListItemAddress(_pvCtx, _piAddrList, 5, &piAddr5);
         if (sciErr.iErr)
         {
+            freeAllocatedSingleString(pstTitle);
             return SET_PROPERTY_ERROR;
         }
 
         if (getAllocatedSingleString(_pvCtx, piAddr5, &pstPosition))
         {
+            freeAllocatedSingleString(pstTitle);
             return SET_PROPERTY_ERROR;
         }
 
@@ -705,6 +734,7 @@ int createTitledBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
         sciErr = getListItemAddress(_pvCtx, _piAddrList, 6, &piAddr6);
         if (sciErr.iErr)
         {
+            freeAllocatedSingleString(pstTitle);
             return SET_PROPERTY_ERROR;
         }
 
@@ -717,6 +747,7 @@ int createTitledBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
 
         if (getAllocatedSingleString(_pvCtx, piAddrFont, &pstFontName))
         {
+            freeAllocatedSingleString(pstTitle);
             return SET_PROPERTY_ERROR;
         }
 
@@ -783,6 +814,7 @@ int createTitledBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
     iBorder = createGraphicObject(__GO_UI_FRAME_BORDER__);
     if (iBorder == 0)
     {
+        freeAllocatedSingleString(pstTitle);
         return SET_PROPERTY_ERROR;
     }
 
@@ -824,6 +856,7 @@ int createTitledBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
         iChildBorder = createBorder(_pvCtx, piAddr2, iBorder);
         if (iChildBorder == 0)
         {
+            freeAllocatedSingleString(pstTitle);
             return SET_PROPERTY_ERROR;
         }
 
@@ -1136,6 +1169,7 @@ int createMatteBorder(void* _pvCtx, int* _piAddrList, int _iObjUID)
     iBorder = createGraphicObject(__GO_UI_FRAME_BORDER__);
     if (iBorder == 0)
     {
+        freeAllocatedSingleString(pstColor);
         return SET_PROPERTY_ERROR;
     }