Fix memory problems

pull/230/head
Кирилл Зимников 2021-07-27 12:08:15 +07:00 committed by Olivier Martin
parent db44d7a99d
commit 2c38df5f30
3 changed files with 6 additions and 3 deletions

View File

@ -268,8 +268,8 @@ int gattlib_disconnect(gatt_connection_t* connection) {
g_main_loop_unref(conn_context->connection_loop); g_main_loop_unref(conn_context->connection_loop);
disconnect_all_notifications(conn_context); disconnect_all_notifications(conn_context);
free(conn_context->adapter);
free(conn_context->adapter->adapter_name); free(conn_context->adapter->adapter_name);
free(conn_context->adapter);
free(connection->context); free(connection->context);
free(connection); free(connection);
@ -598,6 +598,7 @@ int gattlib_discover_char_range(gatt_connection_t* connection, int start, int en
} else { } else {
characteristic_list[count].handle = 0; characteristic_list[count].handle = 0;
characteristic_list[count].value_handle = 0; characteristic_list[count].value_handle = 0;
characteristic_list[count].properties = 0;
const gchar *const * flags = org_bluez_gatt_characteristic1_get_flags(characteristic_proxy); const gchar *const * flags = org_bluez_gatt_characteristic1_get_flags(characteristic_proxy);
for (; *flags != NULL; flags++) { for (; *flags != NULL; flags++) {
@ -683,6 +684,7 @@ static void add_characteristics_from_service(gattlib_context_t* conn_context, GD
characteristic_list[*count].handle = handle; characteristic_list[*count].handle = handle;
characteristic_list[*count].value_handle = handle; characteristic_list[*count].value_handle = handle;
characteristic_list[*count].properties = 0;
const gchar *const * flags = org_bluez_gatt_characteristic1_get_flags(characteristic); const gchar *const * flags = org_bluez_gatt_characteristic1_get_flags(characteristic);
for (; *flags != NULL; flags++) { for (; *flags != NULL; flags++) {

View File

@ -351,8 +351,10 @@ int gattlib_adapter_close(void* adapter)
{ {
struct gattlib_adapter *gattlib_adapter = adapter; struct gattlib_adapter *gattlib_adapter = adapter;
g_object_unref(gattlib_adapter->device_manager); if (gattlib_adapter->device_manager)
g_object_unref(gattlib_adapter->device_manager);
g_object_unref(gattlib_adapter->adapter_proxy); g_object_unref(gattlib_adapter->adapter_proxy);
free(gattlib_adapter->adapter_name);
free(gattlib_adapter); free(gattlib_adapter);
return GATTLIB_SUCCESS; return GATTLIB_SUCCESS;

View File

@ -102,7 +102,6 @@ static gboolean on_handle_characteristic_property_change(
&uuid, data, data_length); &uuid, data, data_length);
// As per https://developer.gnome.org/glib/stable/glib-GVariant.html#g-variant-iter-loop, clean up `key` and `value`. // As per https://developer.gnome.org/glib/stable/glib-GVariant.html#g-variant-iter-loop, clean up `key` and `value`.
g_free(key);
g_variant_unref(value); g_variant_unref(value);
break; break;
} }