mirror of https://github.com/labapart/gattlib
Fix memory problems
parent
db44d7a99d
commit
2c38df5f30
|
@ -268,8 +268,8 @@ int gattlib_disconnect(gatt_connection_t* connection) {
|
|||
g_main_loop_unref(conn_context->connection_loop);
|
||||
disconnect_all_notifications(conn_context);
|
||||
|
||||
free(conn_context->adapter);
|
||||
free(conn_context->adapter->adapter_name);
|
||||
free(conn_context->adapter);
|
||||
|
||||
free(connection->context);
|
||||
free(connection);
|
||||
|
@ -598,6 +598,7 @@ int gattlib_discover_char_range(gatt_connection_t* connection, int start, int en
|
|||
} else {
|
||||
characteristic_list[count].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);
|
||||
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].value_handle = handle;
|
||||
characteristic_list[*count].properties = 0;
|
||||
|
||||
const gchar *const * flags = org_bluez_gatt_characteristic1_get_flags(characteristic);
|
||||
for (; *flags != NULL; flags++) {
|
||||
|
|
|
@ -351,8 +351,10 @@ int gattlib_adapter_close(void* 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);
|
||||
free(gattlib_adapter->adapter_name);
|
||||
free(gattlib_adapter);
|
||||
|
||||
return GATTLIB_SUCCESS;
|
||||
|
|
|
@ -102,7 +102,6 @@ static gboolean on_handle_characteristic_property_change(
|
|||
&uuid, data, data_length);
|
||||
|
||||
// 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);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue