[Problem] There are some memory leak in code
[Cause & Measure] Fix memory leak
324 bytes in 18 blocks are definitely lost in loss record 1,471 of 1,512
at 0x48458E8: malloc (vg_replace_malloc.c:299)
by 0x4B9E271: g_variant_get (gvariant.c:5368)
by 0x12DAC5: _bt_get_remote_device_info_by_object_path (bt-service-device.c:516)
by 0x11A295: __bt_device_property_changed_event (bt-service-event-receiver.c:1076)
by 0x11A295: _bt_handle_property_changed_event (bt-service-event-receiver.c:1403)
by 0x11D235: __bt_manager_event_filter (bt-service-event-receiver.c:2885)
504 bytes in 72 blocks are definitely lost in loss record 1,479 of 1,512
at 0x48458E8: malloc (vg_replace_malloc.c:299)
by 0x4B9E271: g_variant_get (gvariant.c:5368)
by 0x12579D: __bt_get_bonded_device_info (bt-service-adapter.c:374)
by 0x12579D: _bt_get_bonded_device_info (bt-service-adapter.c:3153)
by 0x143815: __bt_bluez_request (bt-request-handler.c:880)
by 0x147439: __bt_service_method (bt-request-handler.c:275)
648 bytes in 36 blocks are definitely lost in loss record 1,486 of 1,512
at 0x48458E8: malloc (vg_replace_malloc.c:299)
by 0x4B9E271: g_variant_get (gvariant.c:5368)
by 0x13402F: _bt_get_device_ida (bt-service-device.c:3563)
by 0x1449ED: __bt_bluez_request (bt-request-handler.c:1792)
by 0x147439: __bt_service_method (bt-request-handler.c:275)
1,008 bytes in 36 blocks are definitely lost in loss record 1,490 of 1,512
at 0x48458E8: malloc (vg_replace_malloc.c:299)
by 0x4B79E89: g_malloc (gmem.c:97)
by 0x4B89755: g_slice_alloc (gslice.c:1007)
by 0x4B5664B: g_array_sized_new (garray.c:193)
by 0x147191: __bt_service_method (bt-request-handler.c:220)
21,852 bytes in 1,214 blocks are definitely lost in loss record 1,509 of 1,512
at 0x48458E8: malloc (vg_replace_malloc.c:299)
by 0x4B9E271: g_variant_get (gvariant.c:5368)
by 0x11B96D: _bt_handle_device_event (bt-service-event-receiver.c:2200)
by 0x11D8B1: __bt_manager_event_filter (bt-service-event-receiver.c:2897)
22,662 (432 direct, 22,230 indirect) bytes in 18 blocks are definitely lost in loss record 1,511 of 1,512
at 0x48458E8: malloc (vg_replace_malloc.c:299)
by 0x4B9E271: g_variant_get (gvariant.c:5368)
by 0x11D17D: __bt_manager_event_filter (bt-service-event-receiver.c:2679)
Change-Id: Ib00c46ac04eff5d62b94bbf31876bd06dac6aa2a
Signed-off-by: Seungyoun Ju <sy39.ju@samsung.com>
GVariant *temp = g_variant_new("(iv)", result, out_var);
g_dbus_method_invocation_return_value(invocation, temp);
GVariant *temp = g_variant_new("(iv)", result, out_var);
g_dbus_method_invocation_return_value(invocation, temp);
-
- g_array_free(out_param1, TRUE);
- out_param1 = NULL;
}
}
/* TODO: MAP? see the if{}else{} above */
}
}
/* TODO: MAP? see the if{}else{} above */
+ g_array_free(out_param1, TRUE);
g_variant_unref(param1);
g_variant_unref(param2);
g_variant_unref(param3);
g_variant_unref(param4);
g_variant_unref(param5);
g_variant_unref(param1);
g_variant_unref(param2);
g_variant_unref(param3);
g_variant_unref(param4);
g_variant_unref(param5);
g_variant_unref(param3);
g_variant_unref(param4);
g_variant_unref(param5);
g_variant_unref(param3);
g_variant_unref(param4);
g_variant_unref(param5);
GDBusProxy *device_proxy;
gchar *address = NULL;
gchar *name = NULL;
GDBusProxy *device_proxy;
gchar *address = NULL;
gchar *name = NULL;
unsigned int cod = 0;
gint rssi = 0;
gboolean trust = FALSE;
unsigned int cod = 0;
gint rssi = 0;
gboolean trust = FALSE;
} else if (!g_strcmp0(key, "Address")) {
g_variant_get(value, "s", &address);
} else if (!g_strcmp0(key, "Alias")) {
} else if (!g_strcmp0(key, "Address")) {
g_variant_get(value, "s", &address);
} else if (!g_strcmp0(key, "Alias")) {
- g_variant_get(value, "s", &name);
+ g_variant_get(value, "s", &alias);
} else if (!g_strcmp0(key, "Name")) {
} else if (!g_strcmp0(key, "Name")) {
- if (!name)
- g_variant_get(value, "s", &name);
+ g_variant_get(value, "s", &name);
} else if (!g_strcmp0(key, "Class")) {
cod = g_variant_get_uint32(value);
} else if (!g_strcmp0(key, "Connected")) {
} else if (!g_strcmp0(key, "Class")) {
cod = g_variant_get_uint32(value);
} else if (!g_strcmp0(key, "Connected")) {
if ((paired == FALSE) && (trust == FALSE)) {
g_free(address);
if ((paired == FALSE) && (trust == FALSE)) {
g_free(address);
g_free(name);
return BLUETOOTH_ERROR_NOT_PAIRED;
}
g_free(name);
return BLUETOOTH_ERROR_NOT_PAIRED;
}
_bt_divide_device_class(&dev_info->device_class, cod);
_bt_divide_device_class(&dev_info->device_class, cod);
- g_strlcpy(dev_info->device_name.name, name,
+ g_strlcpy(dev_info->device_name.name, alias ? alias : name,
BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
dev_info->rssi = rssi;
BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
dev_info->rssi = rssi;
dev_info->connected = connected;
ret = BLUETOOTH_ERROR_NONE;
g_free(address);
dev_info->connected = connected;
ret = BLUETOOTH_ERROR_NONE;
g_free(address);
g_free(name);
return ret;
g_free(name);
return ret;
- if (out_param1)
- g_array_free(out_param1, TRUE);
-
return BLUETOOTH_ERROR_NONE;
fail:
if (out_param1 != NULL)
return BLUETOOTH_ERROR_NONE;
fail:
if (out_param1 != NULL)
}
_bt_add_headset_to_list(type, BT_STATE_DISCONNECTING, address);
}
_bt_add_headset_to_list(type, BT_STATE_DISCONNECTING, address);
- if (out_param1)
- g_array_free(out_param1, TRUE);
-
return BLUETOOTH_ERROR_NONE;
fail:
if (out_param1 != NULL)
return BLUETOOTH_ERROR_NONE;
fail:
if (out_param1 != NULL)
return ret;
}
g_free(uuid);
return ret;
}
g_free(uuid);
- if (out_param1)
- g_array_free(out_param1, TRUE);
return BLUETOOTH_ERROR_NONE;
fail:
return BLUETOOTH_ERROR_NONE;
fail:
g_variant_get(tmp_value, "s", &address);
g_variant_unref(tmp_value);
g_variant_get(tmp_value, "s", &address);
g_variant_unref(tmp_value);
- dev_info->address = g_strdup(address);
- dev_info->name = g_strdup(name);
- g_free(name);
+ dev_info->address = address;
+ dev_info->name = name;
g_variant_unref(value);
} else {
BT_ERR("result is NULL\n");
g_variant_unref(value);
} else {
BT_ERR("result is NULL\n");
retv_if(device_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
retv_if(device_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
- NULL, BT_BLUEZ_NAME,
- device_path, BT_DEVICE_INTERFACE, NULL, NULL);
+ NULL, BT_BLUEZ_NAME,
+ device_path, BT_DEVICE_INTERFACE, NULL, NULL);
g_free(device_path);
if (!device_proxy) {
BT_ERR("Unable to get proxy");
return BLUETOOTH_ERROR_INTERNAL;
}
g_free(device_path);
if (!device_proxy) {
BT_ERR("Unable to get proxy");
return BLUETOOTH_ERROR_INTERNAL;
}
- result = g_dbus_proxy_call_sync(device_proxy, "GetIDAddress",
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error);
-
+ result = g_dbus_proxy_call_sync(device_proxy, "GetIDAddress", NULL,
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (result == NULL) {
BT_ERR("Failed to get device ID address");
if (error != NULL) {
if (result == NULL) {
BT_ERR("Failed to get device ID address");
if (error != NULL) {
- BT_ERR("Error occured in Proxy call [%s]\n", error->message);
+ BT_ERR("Error occured in Proxy call [%s]", error->message);
g_error_free(error);
}
g_object_unref(device_proxy);
return BLUETOOTH_ERROR_INTERNAL;
}
g_error_free(error);
}
g_object_unref(device_proxy);
return BLUETOOTH_ERROR_INTERNAL;
}
- g_variant_get(result , "(s)", &idaddress);
- g_variant_unref(result);
-
+ g_variant_get(result , "(&s)", &idaddress);
if (idaddress == NULL) {
BT_ERR("No paired device");
if (idaddress == NULL) {
BT_ERR("No paired device");
- g_object_unref(device_proxy);
- return BLUETOOTH_ERROR_NOT_PAIRED;
- }
-
- BT_DBG("ID Address:%s", idaddress);
-
- if (idaddress)
+ ret = BLUETOOTH_ERROR_NOT_PAIRED;
+ } else {
+ DBG_SECURE("ID Address : %s", idaddress);
_bt_convert_addr_string_to_type(id_address->addr, idaddress);
_bt_convert_addr_string_to_type(id_address->addr, idaddress);
- else
- ret = BLUETOOTH_ERROR_INTERNAL;
+ g_variant_unref(result);
g_object_unref(device_proxy);
return ret;
g_object_unref(device_proxy);
return ret;
le_dev_info = g_malloc0(sizeof(bt_remote_le_dev_info_t));
le_dev_info = g_malloc0(sizeof(bt_remote_le_dev_info_t));
- g_variant_get(msg, "(syyii@ay)", &le_dev_info->address,
- &le_dev_info->addr_type,
- &le_dev_info->adv_type,
- &le_dev_info->rssi,
- &le_dev_info->adv_data_len,
- &value);
+ g_variant_get(msg, "(&syyii@ay)", &le_dev_info->address,
+ &le_dev_info->addr_type,
+ &le_dev_info->adv_type,
+ &le_dev_info->rssi,
+ &le_dev_info->adv_data_len,
+ &value);
if (value == NULL) {
_bt_free_le_device_info(le_dev_info);
if (value == NULL) {
_bt_free_le_device_info(le_dev_info);
#ifdef TIZEN_FEATURE_BT_DPM
int desktop_state = DPM_BT_ERROR;
#endif
#ifdef TIZEN_FEATURE_BT_DPM
int desktop_state = DPM_BT_ERROR;
#endif
- ret_if(_bt_is_discovering() == FALSE &&
- _bt_is_le_scanning() == FALSE);
+ if (_bt_is_discovering() == FALSE &&
+ _bt_is_le_scanning() == FALSE) {
+ g_variant_unref(value);
+ return;
+ }
cache_info = g_malloc0(sizeof(bt_cache_info_t));
cache_info = g_malloc0(sizeof(bt_cache_info_t));