increase code quality(static analysis) 16/178916/3 accepted/tizen/unified/20180515.063848 submit/tizen/20180515.045647
authorYoungjae Shin <yj99.shin@samsung.com>
Tue, 15 May 2018 01:09:26 +0000 (10:09 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Tue, 15 May 2018 04:34:17 +0000 (13:34 +0900)
Change-Id: I8c40f20fa9c750824bffb83c028c7cdeacaa7265

externals/MsgSpamFilter.cpp
vobject-engine/VMessage.c

index 6b63b1a..2ba546a 100755 (executable)
@@ -162,7 +162,7 @@ bool MsgCheckFilter(MsgDbHandler *pDbHandle, MSG_MESSAGE_INFO_S *pMsgInfo)
 
        int fileSize = 0;
        bool bFiltered = false;
-       int tmpLen = 0;
+       unsigned int tmpLen = 0;
        for (int i = 1; i <= rowCnt; i++) {
                memset(filterValue, 0x00, sizeof(filterValue));
 
index 280426a..039a720 100755 (executable)
@@ -840,18 +840,16 @@ VTree* vmsg_decode(char *pMsgRaw)
                                if (!strncmp(szMsgBegin, "VCARD", strlen("VCARD"))) {
                                        VDATA_TRACE("pVTree: %s", pVTree);
                                        pVCard = vcard_decode(pVTree);
-                                       if (pCurrent) {
+                                       if (pCurrent)
                                                pCurrent->pNext = pVCard;
-                                       }
                                        pCurrent = pVCard;
 
                                        dLen = ((strstr(pMsgRaw, "END:VCARD") + 9) - pMsgRaw);
                                        pMsgRaw += dLen;
                                } else {
                                        if (!strncmp(szMsgBegin, "VMSG", strlen("VMSG"))) {
-                                               if ((pVMsg = (VTree*)calloc(1, sizeof(VTree))) == NULL) {
+                                               if ((pVMsg = (VTree*)calloc(1, sizeof(VTree))) == NULL)
                                                        goto CATCH;
-                                               }
                                                memset(pVMsg, 0x00, sizeof(VTree));
 
                                                pVMsg->treeType = VMESSAGE;
@@ -860,9 +858,8 @@ VTree* vmsg_decode(char *pMsgRaw)
                                                pVMsg->pNext = NULL;
                                                pCurrent = pVMsg;
                                        } else if (!strncmp(szMsgBegin, "VBODY", strlen("VBODY"))) {
-                                               if ((pVBody = (VTree*)calloc(1, sizeof(VTree))) == NULL) {
+                                               if ((pVBody = (VTree*)calloc(1, sizeof(VTree))) == NULL)
                                                        goto CATCH;
-                                               }
 
                                                memset(pVBody, 0x00, sizeof(VTree));
                                                pVBody->treeType = VBODY;
@@ -905,8 +902,6 @@ VTree* vmsg_decode(char *pMsgRaw)
 
                                if ((pTemp = (VObject*)calloc(1, sizeof(VObject))) == NULL)
                                        goto CATCH;
-
-                               memset(pTemp, 0, sizeof(VObject));
                                pTemp->property = type;
 
                                if (pCurrent) {
@@ -917,6 +912,9 @@ VTree* vmsg_decode(char *pMsgRaw)
                                                pCurrent->pCur->pSibling = pTemp;
                                                pCurrent->pCur = pTemp;
                                        }
+                               } else {
+                                       free(pTemp);
+                                       pTemp = NULL;
                                }
 
                                break;
@@ -934,21 +932,22 @@ VTree* vmsg_decode(char *pMsgRaw)
                        pMsgRaw += dLen;
 
                        if (param_status != true) {
-
                                if ((pTmpParam = (VParam*)calloc(1, sizeof(VParam))) == NULL)
                                        goto CATCH;
 
-                               param_status = true;
-                               if (pCurrent)
+                               if (pCurrent) {
                                        pCurrent->pCur->pParam = pTmpParam;
-                               memset(pTmpParam, 0x00, sizeof(VParam));
+                                       param_status = true;
+                               } else {
+                                       VDATA_TRACE("pCurrent is NULL");
+                                       goto CATCH;
+                               }
                                VDATA_TRACE("pTmpParam : %p", pTmpParam);
                        } else {
                                if ((pTmpParam->pNext = (VParam*)calloc(1, sizeof(VParam))) == NULL)
                                        goto CATCH;
 
                                pTmpParam = pTmpParam->pNext;
-                               memset(pTmpParam, 0x00, sizeof(VParam));
                                VDATA_TRACE("pTmpParam : %p", pTmpParam);
                        }
 
@@ -1065,12 +1064,10 @@ char* vmsg_encode(VTree *pVMsgRaw)
        int                     total = 0;
        int                     cnt = 0;
 
-       if (!pVMsgRaw || !pVMsgRaw->pTop) {
+       if (!pVMsgRaw || !pVMsgRaw->pTop)
                return NULL;
-       }
 
        for (; cnt < pVMsgRaw->pTop->valueCount; cnt++) {
-
                if (pVMsgRaw->pTop->pszValue[cnt] == NULL)  {
                        VDATA_TRACE("pVMsgRaw->pTop->valueCount : %d", pVMsgRaw->pTop->valueCount);
                        VDATA_TRACE("pVMsgRaw->pTop->pszValue[%d] : %s", cnt, pVMsgRaw->pTop->pszValue[cnt]);