fix svace issues
[platform/core/messaging/msg-service.git] / vobject-engine / VMessage.c
index 782733d..50da899 100755 (executable)
@@ -788,7 +788,6 @@ VTree* vmsg_decode(char *pMsgRaw)
        int param_status = false;
        int numberedParam = 0;
        int enc = 0;
-       int start_status = 0;
        char* temp = NULL;
        char* pVTree = NULL;
        bool vmsg_ended = false;
@@ -841,19 +840,16 @@ VTree* vmsg_decode(char *pMsgRaw)
                                if (!strncmp(szMsgBegin, "VCARD", strlen("VCARD"))) {
                                        VDATA_TRACE("pVTree: %s", pVTree);
                                        pVCard = vcard_decode(pVTree);
-                                       pCurrent->pNext = pVCard;
+                                       if (pCurrent) {
+                                               pCurrent->pNext = pVCard;
+                                       }
                                        pCurrent = pVCard;
 
                                        dLen = ((strstr(pMsgRaw, "END:VCARD") + 9) - pMsgRaw);
                                        pMsgRaw += dLen;
                                } else {
-
-                                       if (start_status == 1)
-                                               goto CATCH;
-
                                        if (!strncmp(szMsgBegin, "VMSG", strlen("VMSG"))) {
                                                if ((pVMsg = (VTree*)calloc(1, sizeof(VTree))) == NULL) {
-                                                       start_status = 1;
                                                        goto CATCH;
                                                }
                                                memset(pVMsg, 0x00, sizeof(VTree));
@@ -865,7 +861,6 @@ VTree* vmsg_decode(char *pMsgRaw)
                                                pCurrent = pVMsg;
                                        } else if (!strncmp(szMsgBegin, "VBODY", strlen("VBODY"))) {
                                                if ((pVBody = (VTree*)calloc(1, sizeof(VTree))) == NULL) {
-                                                       start_status = 1;
                                                        goto CATCH;
                                                }
 
@@ -1023,7 +1018,7 @@ VTree* vmsg_decode(char *pMsgRaw)
        VDATA_TRACE("pMsgRawTmp: %s", pMsgRawTmp);
        /* VFREE(pMsgRawTmp); */
 
-       if (pVMsg->pTop == NULL) {
+       if (pVMsg && pVMsg->pTop == NULL) {
                VDATA_TRACE("pVMsg->Top: NULL");
                goto CATCH;
        }
@@ -1063,6 +1058,10 @@ char* vmsg_encode(VTree *pVMsgRaw)
        int                     total = 0;
        int                     cnt = 0;
 
+       if (!pVMsgRaw || !pVMsgRaw->pTop) {
+               return NULL;
+       }
+
        for (; cnt < pVMsgRaw->pTop->valueCount; cnt++) {
 
                if (pVMsgRaw->pTop->pszValue[cnt] == NULL)  {
@@ -1163,8 +1162,6 @@ char* vmsg_encode(VTree *pVMsgRaw)
                                                break;
                                }
                        }
-
-
                }
 
                switch (pTmpTree->treeType) {