d2d-conv-manager: fix memory leaks and remove unused variables 53/114153/1
authorHongkuk, Son <hongkuk.son@samsung.com>
Wed, 8 Feb 2017 06:22:50 +0000 (15:22 +0900)
committerHongkuk Son <hongkuk.son@samsung.com>
Fri, 10 Feb 2017 07:34:51 +0000 (23:34 -0800)
-http://suprem.sec.samsung.net/jira/browse/TSAM-12805
-Memory leaks were detected by LSAN(leak sanitizer).

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

daemon/discovery_provider/IotconDiscoveryProvider.cpp
lib/conv_lib_payload.cpp

index eaa2d69..a9b6df1 100755 (executable)
@@ -279,12 +279,10 @@ string conv::IotconDiscoveryProvider::__generate_discovery_key(char* uri_path, c
 int conv::IotconDiscoveryProvider::__add_iot_resource(iotcon_remote_resource_h resource)
 {
        _D("__add_iot_resource called..");
-       ResourceHandle  iot_resource_h;
 
        char* resource_uri_path = NULL;
        char* resource_host = NULL;
        iotcon_resource_types_h resource_types = NULL;
-       string resourceType;
        iotcon_resource_interfaces_h resource_interfaces;
 
        // uri_path , host_address
index 8555cee..27a4ad1 100755 (executable)
@@ -143,6 +143,7 @@ EXTAPI int conv_payload_get_app_control(conv_payload_h handle, const char* key,
        ret = app_control_import_from_bundle(*app_control, appctl_bundle);
 
        bundle_free(appctl_bundle);
+       free(str);
 
        IF_FAIL_RETURN_TAG(ret == APP_CONTROL_ERROR_NONE, CONV_ERROR_INVALID_PARAMETER, _E, "app_control load failed");
 
@@ -156,9 +157,13 @@ EXTAPI int conv_payload_set_byte(conv_payload_h handle, const char* key, int len
        ASSERT_NOT_NULL(key);
        ASSERT_NOT_NULL(value);
 
-       std::string str_value = g_base64_encode(value, length);
+       char *c_value = g_base64_encode(value, length);
+
+       std::string str_value = c_value;
        handle->jpayload.set(NULL, key, str_value);
 
+       g_free(c_value);
+
        return CONV_ERROR_NONE;
 }
 
@@ -178,9 +183,14 @@ EXTAPI int conv_payload_get_byte(conv_payload_h handle, const char* key, int* le
        IF_FAIL_RETURN_TAG(handle->jpayload.get(NULL, key, &str), CONV_ERROR_INVALID_PARAMETER, _E, "Value load failed");
        gsize unsigned_len;
 
-       *value = g_base64_decode(g_strdup(str.c_str()), &unsigned_len);
+       char *str_cstr;
+       str_cstr = g_strdup(str.c_str());
+
+       *value = g_base64_decode(str_cstr, &unsigned_len);
        *length = (int)unsigned_len;
 
+       g_free(str_cstr);
+
        ASSERT_ALLOC(*value);
 
        return CONV_ERROR_NONE;