Modified for Svace Issue (MEMORY_LEAK.EX) 69/123569/2
authorSegwon <segwon.han@samsung.com>
Thu, 6 Apr 2017 06:25:17 +0000 (15:25 +0900)
committerSegwon <segwon.han@samsung.com>
Thu, 6 Apr 2017 06:54:16 +0000 (15:54 +0900)
Issue : Dynamically allocated objects were not freed from macro of "IF_FAIL_VOID_TAG".

Signed-off-by: Segwon <segwon.han@samsung.com>
Change-Id: I4f417169967f4639b9b41ca23a456d3c94af2ba8

lib/conv_lib_service.cpp

index ea99bf755a71b86b4dd513ad2f929863aca5339d..5acc5116759fe77bc71826d074b757404cc2885a 100755 (executable)
@@ -73,6 +73,7 @@ static void conv_subject_cb(const char* subject, int req_id, int error, json dat
                return;
        }
 
+       conv_error_e conv_error;
        _conv_service_callback_info* callback_info = it->second;
 
        conv_service_h service_handle = new(std::nothrow) _conv_service_handle();
@@ -87,22 +88,23 @@ static void conv_subject_cb(const char* subject, int req_id, int error, json dat
 
        if (!channel.isEmpty()) {
                channel_handle = new(std::nothrow) _conv_channel_handle();
-               IF_FAIL_VOID_TAG(channel_handle, _E, "Memory allocation failed");
+               IF_FAIL_CATCH_TAG(channel_handle, _E, "Memory allocation failed");
                channel_handle->jchannel = channel;
        }
 
        if (!payload.isEmpty() || binary_length > 0) {
                payload_handle = new(std::nothrow) _conv_payload_handle();
-               IF_FAIL_VOID_TAG(payload_handle, _E, "Memory allocation failed");
+               IF_FAIL_CATCH_TAG(payload_handle, _E, "Memory allocation failed");
 
                payload_handle->jpayload = payload;
                payload_handle->binary_length = binary_length;
                payload_handle->binary = binary;
        }
 
-       conv_error_e conv_error = (conv_error_e)error;
+       conv_error = (conv_error_e)error;
        callback_info->cb(service_handle, channel_handle, conv_error, payload_handle, callback_info->user_data);
 
+CATCH:
        if (payload_handle) {
                delete payload_handle;
        }
@@ -150,13 +152,15 @@ static void conv_connect_subject_cb(const char* subject, int req_id, int error,
        service_handle->connection_state = CONV_SERVICE_CONNECTION_STATE_CONNECTED;
 
        conv_payload_h payload_handle = new(std::nothrow) _conv_payload_handle();
-       IF_FAIL_VOID_TAG(payload_handle, _E, "Memory allocation failed");
+       IF_FAIL_CATCH_TAG(payload_handle, _E, "Memory allocation failed");
 
        payload_handle->jpayload = payload;
 
        callback_info->cb(service_handle, CONV_ERROR_NONE, payload_handle, callback_info->user_data);
 
        delete payload_handle;
+
+CATCH:
        delete service_handle;
 }