[Title] fix prevent defects on libvmodem/libvgsm_call.c, libvgsm_data.c, libvgsm_disp...
authorSooyoung Ha <yoosah.ha@samsung.com>
Wed, 9 Jan 2013 14:05:00 +0000 (23:05 +0900)
committerSooyoung Ha <yoosah.ha@samsung.com>
Wed, 9 Jan 2013 14:05:00 +0000 (23:05 +0900)
[Desc.] Resource leak and null check.
[Issue] Prevent CID 33798~33802, 33899

libvmodem/libvgsm_call.c
libvmodem/libvgsm_data.c
libvmodem/libvgsm_display.c
libvmodem/libvgsm_edb.c
libvmodem/libvgsm_hdlc.c

index 7ea492c..c4e7dc2 100644 (file)
@@ -43,11 +43,11 @@ int vgsm_call_make(LXT_HANDLE* handle, gsm_call_info_t callinfo)
 
        length = sizeof(gsm_call_info_t);
        
-       unsigned char * pdata = (unsigned char *) malloc(length);
-
        if( handle == NULL )
                return -1;
 
+       unsigned char * pdata = (unsigned char *) malloc(length);
+
        if (!pdata)
                return (-1);
 
index 909f8c1..179da40 100644 (file)
@@ -34,11 +34,11 @@ int vgsm_data_status(LXT_HANDLE* handle, GSM_DataCallStatus status)
        int nretn = 0;
        int     length = 4;
 
-       unsigned char * pdata = (unsigned char *) malloc(length);
-
        if( handle == NULL )
                return -1;
 
+       unsigned char * pdata = (unsigned char *) malloc(length);
+
        if (!pdata)
                return (-1);
 
index 53771c9..b8a46cc 100644 (file)
@@ -34,11 +34,11 @@ int vgsm_display_icon_information(LXT_HANDLE* handle, disp_icon_info_t info)
        int nretn = 0;
        int     length = 5; 
 
-       unsigned char * pdata = (unsigned char *) malloc(length);
-
        if( handle == NULL )
                return -1;
 
+       unsigned char * pdata = (unsigned char *) malloc(length);
+
        if (!pdata)
                return (-1);
 
index 6e6fd86..788986c 100644 (file)
 
 int vgsm_get_pb_edb(LXT_HANDLE * handle)
 {
+       if( handle == NULL )
+               return -1;
+       
        printf("[LIBVGSM-SIM] vgsm_get_pb_edb\n");
 
        _Pb_edb *pb_edb;
        pb_edb = malloc(sizeof(_Pb_edb));
+       if(!pb_edb)
+               return -1;
        memset(pb_edb,0,sizeof(_Pb_edb));
        int ret;
        
-       if( handle == NULL )
-               return -1;
-       
        ret =  lxt_msg_send_message
                (
                        handle->fd,
index 5374657..9470625 100644 (file)
@@ -100,13 +100,13 @@ void FreeAllMultiNodeList()
 
 void PushHDLCMultiFrameInfo(HDLCFrame_t const* pframe)
 {
-       TRACE(MSGL_VGSM_INFO, "\n");
-
-       HDLCNode* pnode = malloc(sizeof(HDLCNode));
-
        if (!pframe)
                return;
 
+       TRACE(MSGL_VGSM_INFO, "\n");
+
+       HDLCNode* pnode = malloc(sizeof(HDLCNode));
+       if(!pnode) return;
        memset(pnode, 0, sizeof(HDLCNode));
 
        pnode->m_HDLCNode.m_Length = pframe->m_Length;