From: Hongkuk, Son Date: Wed, 8 Feb 2017 06:22:50 +0000 (+0900) Subject: d2d-conv-manager: fix memory leaks and remove unused variables X-Git-Tag: accepted/tizen/common/20170210.170711^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=10bc6bb11746d2c9a0bd04a72354aa8bf0401771;p=platform%2Fcore%2Fconvergence%2Fd2d-conv-manager.git d2d-conv-manager: fix memory leaks and remove unused variables -http://suprem.sec.samsung.net/jira/browse/TSAM-12805 -Memory leaks were detected by LSAN(leak sanitizer). Signed-off-by: Hongkuk, Son Change-Id: I8c79f0d697a97f9c629008b7da99be0a0e229ace --- diff --git a/daemon/discovery_provider/IotconDiscoveryProvider.cpp b/daemon/discovery_provider/IotconDiscoveryProvider.cpp index eaa2d69..a9b6df1 100755 --- a/daemon/discovery_provider/IotconDiscoveryProvider.cpp +++ b/daemon/discovery_provider/IotconDiscoveryProvider.cpp @@ -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 diff --git a/lib/conv_lib_payload.cpp b/lib/conv_lib_payload.cpp index 8555cee..27a4ad1 100755 --- a/lib/conv_lib_payload.cpp +++ b/lib/conv_lib_payload.cpp @@ -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;