d2d-conv-manager: fix svace_2.2 issues 86/104086/1 accepted/tizen/common/20161212.185608 accepted/tizen/mobile/20161213.002908 accepted/tizen/tv/20161213.002912 accepted/tizen/wearable/20161213.002932 submit/tizen/20161212.090406
authorHongkuk, Son <hongkuk.son@samsung.com>
Mon, 12 Dec 2016 08:49:15 +0000 (17:49 +0900)
committerHongkuk Son <hongkuk.son@samsung.com>
Mon, 12 Dec 2016 08:53:54 +0000 (00:53 -0800)
WID 17710445 - NULL_AFTER_DEREF
WID 17713990 - DEREF_AFTER_NULL.EX

Signed-off-by: Hongkuk, Son <hongkuk.son@samsung.com>
Change-Id: I0549f5c5e8aedb85cdc68fcffa6cb2bd1dddf37e

msf_tizen_client/src/Channel.cpp

index f001771..3512ad9 100755 (executable)
@@ -973,13 +973,18 @@ int Channel::callback_lws_mirror(struct lws *wsi,
                        }
 
                        this_ptr->cl_data = (unsigned char*)realloc(this_ptr->cl_data, this_ptr->cl_data_size + len + 1);
-                       memcpy(&(this_ptr->cl_data[this_ptr->cl_data_size]), (char*)in, len);
-                       this_ptr->cl_data_size += len;
-                       this_ptr->cl_data[this_ptr->cl_data_size] = '\0';
-                       this_ptr->connectionHandler->resetLastPingReceived();
+
+                       if (this_ptr->cl_data) {
+                               memcpy(&(this_ptr->cl_data[this_ptr->cl_data_size]), (char*)in, len);
+                               this_ptr->cl_data_size += len;
+                               this_ptr->cl_data[this_ptr->cl_data_size] = '\0';
+                               this_ptr->connectionHandler->resetLastPingReceived();
+                       }
 
                        if (lws_remaining_packet_payload(wsi) == 0) {
-                               this_ptr->json_parse((char*)this_ptr->cl_data);
+                               if (this_ptr->cl_data) {
+                                       this_ptr->json_parse((char*)this_ptr->cl_data);
+                               }
 
                                if (this_ptr->eventType == CONNECT_EVENT) {
                                        this_ptr->handleConnectMessage(this_ptr->UID);
@@ -1181,8 +1186,15 @@ unsigned char *Channel::prepareMessageMap(string method, string event,
                                                                                int payload_size) {
        int l = 0;
        int header_size = 0;
+       int data_len = 0;
+
+       if (data) {
+               data_len = strlen(data);
+       } else {
+               data_len = 0;
+       }
 
-       int prepare_buf_size = LWS_SEND_BUFFER_PRE_PADDING + strlen(data) + payload_size + 512 + LWS_SEND_BUFFER_POST_PADDING;
+       int prepare_buf_size = LWS_SEND_BUFFER_PRE_PADDING + data_len + payload_size + 512 + LWS_SEND_BUFFER_POST_PADDING;
        unsigned char *prepare_buf = new unsigned char[prepare_buf_size];
 
        if (payload) {