diff options
author | Sven Gothel <[email protected]> | 2020-02-05 02:44:14 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-02-05 02:44:14 +0100 |
commit | ce0cb79cb0bbe745f1c197cdeaa3240bb3d76df8 (patch) | |
tree | 01a6f927dfa2bed1c8014dd6a9d3722c1c2fb588 | |
parent | 880272b810a0d61a57db9acda5e3d6db1f77c91d (diff) |
Re-add dropped g_bytes_unref(..)/g_free(..) where it still applies
This was dropped in the gdbus-codegen related commits: 48137326978655fa7a8092f687200eca3e8eb68f
-rw-r--r-- | src/BluetoothGattCharacteristic.cpp | 16 | ||||
-rw-r--r-- | src/BluetoothGattDescriptor.cpp | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/BluetoothGattCharacteristic.cpp b/src/BluetoothGattCharacteristic.cpp index 028013a9..a087ae68 100644 --- a/src/BluetoothGattCharacteristic.cpp +++ b/src/BluetoothGattCharacteristic.cpp @@ -147,6 +147,9 @@ std::vector<unsigned char> BluetoothGattCharacteristic::read_value (uint16_t off GBytes *result_gbytes = g_variant_get_data_as_bytes(result_variant); std::vector<unsigned char> result = from_gbytes_to_vector(result_gbytes); + /* free the gbytes array */ + g_bytes_unref(result_gbytes); + return result; } @@ -177,6 +180,9 @@ bool BluetoothGattCharacteristic::write_value ( &error ); + /* freeing the GBytes allocated inside from_vector_to_gbytes function */ + g_bytes_unref(arg_value_gbytes); + handle_error(error); return result; @@ -268,8 +274,16 @@ std::vector<unsigned char> BluetoothGattCharacteristic::get_value () { GVariant *value_variant = gatt_characteristic1_get_value (object); GBytes *value_gbytes = g_variant_get_data_as_bytes(value_variant); + std::vector<unsigned char> result; + + try { + result = from_gbytes_to_vector(value_gbytes); + } catch (std::exception &e) { + g_bytes_unref(value_gbytes); + throw e; + } - std::vector<unsigned char> result = from_gbytes_to_vector(value_gbytes); + g_bytes_unref(value_gbytes); return result; } diff --git a/src/BluetoothGattDescriptor.cpp b/src/BluetoothGattDescriptor.cpp index f3810bdf..ff5f804d 100644 --- a/src/BluetoothGattDescriptor.cpp +++ b/src/BluetoothGattDescriptor.cpp @@ -149,6 +149,8 @@ std::vector<unsigned char> BluetoothGattDescriptor::read_value (uint16_t offset) std::vector<unsigned char> result = from_chars_to_vector(result_chars); + g_free(result_chars); + return result; } |