coverity issue#109258
[platform/core/messaging/msg-service.git] / vobject-engine / VMessage.c
index 2e0aeef..18c80a9 100755 (executable)
@@ -869,7 +869,8 @@ VTree* vmsg_decode(char *pMsgRaw)
                                                pVBody->pTop = NULL;
                                                pVBody->pCur = NULL;
                                                pVBody->pNext = NULL;
-                                               pCurrent->pNext = pVBody;
+                                               if (pCurrent)
+                                                       pCurrent->pNext = pVBody;
                                                pCurrent = pVBody;
                                        }
                                }
@@ -908,12 +909,14 @@ VTree* vmsg_decode(char *pMsgRaw)
                                memset(pTemp, 0, sizeof(VObject));
                                pTemp->property = type;
 
-                               if (pCurrent->pTop == NULL) {
-                                       pCurrent->pTop = pTemp;
-                                       pCurrent->pCur = pTemp;
-                               } else {
-                                       pCurrent->pCur->pSibling = pTemp;
-                                       pCurrent->pCur = pTemp;
+                               if (pCurrent) {
+                                       if (pCurrent->pTop == NULL) {
+                                               pCurrent->pTop = pTemp;
+                                               pCurrent->pCur = pTemp;
+                                       } else {
+                                               pCurrent->pCur->pSibling = pTemp;
+                                               pCurrent->pCur = pTemp;
+                                       }
                                }
 
                                break;
@@ -936,7 +939,8 @@ VTree* vmsg_decode(char *pMsgRaw)
                                        goto CATCH;
 
                                param_status = true;
-                               pCurrent->pCur->pParam = pTmpParam;
+                               if (pCurrent)
+                                       pCurrent->pCur->pParam = pTmpParam;
                                memset(pTmpParam, 0x00, sizeof(VParam));
                                VDATA_TRACE("pTmpParam : %p", pTmpParam);
                        } else {
@@ -1028,13 +1032,19 @@ VTree* vmsg_decode(char *pMsgRaw)
                goto CATCH1;
        }
        VDATA_TRACE_END
+       VFREE(pTemp);
+       VFREE(pTmpParam);
+       VFREE(pVBody);
        return pVMsg;
 
 CATCH:
        VFREE(pTemp);
 CATCH1:
+       VFREE(pTemp);
        VFREE(szMsgBegin);
        VFREE(pMsgRawTmp);
+       VFREE(pTmpParam);
+       VFREE(pVBody);
        vmsg_free_vtree_memory(pVMsg);
        VDATA_TRACE_END
        return NULL;