From: Youngjae Shin Date: Tue, 15 May 2018 01:09:26 +0000 (+0900) Subject: increase code quality(static analysis) X-Git-Tag: submit/tizen/20180515.045647^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2be64a72e9b06088049f9ec5d76a713c745607fe;p=platform%2Fcore%2Fmessaging%2Fmsg-service.git increase code quality(static analysis) Change-Id: I8c40f20fa9c750824bffb83c028c7cdeacaa7265 --- diff --git a/externals/MsgSpamFilter.cpp b/externals/MsgSpamFilter.cpp index 6b63b1a..2ba546a 100755 --- a/externals/MsgSpamFilter.cpp +++ b/externals/MsgSpamFilter.cpp @@ -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)); diff --git a/vobject-engine/VMessage.c b/vobject-engine/VMessage.c index 280426a..039a720 100755 --- a/vobject-engine/VMessage.c +++ b/vobject-engine/VMessage.c @@ -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]);