Skip to content
This repository was archived by the owner on Jan 4, 2023. It is now read-only.

Commit 6a643b3

Browse files
Tzafrir Poupkopetreeftime
authored andcommitted
Fix native memory leak
Objects obtained via g_dbus_object_manager_get_objects Should be released by g_object_unref Signed-off-by: Tzafrir Poupko <[email protected]>
1 parent 0194377 commit 6a643b3

File tree

5 files changed

+8
-0
lines changed

5 files changed

+8
-0
lines changed

src/BluetoothAdapter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ std::vector<std::unique_ptr<BluetoothDevice>> BluetoothAdapter::get_devices()
162162
if (p != nullptr)
163163
vector.push_back(std::move(p));
164164
}
165+
g_list_free_full(objects, g_object_unref);
165166

166167
return vector;
167168
}

src/BluetoothDevice.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ std::vector<std::unique_ptr<BluetoothGattService>> BluetoothDevice::get_services
222222
if (p != nullptr)
223223
vector.push_back(std::move(p));
224224
}
225+
g_list_free_full(objects, g_object_unref);
225226

226227
return vector;
227228
}

src/BluetoothGattCharacteristic.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ std::vector<std::unique_ptr<BluetoothGattDescriptor>> BluetoothGattCharacteristi
308308
if (p != nullptr)
309309
vector.push_back(std::move(p));
310310
}
311+
g_list_free_full(objects, g_object_unref);
311312

312313
return vector;
313314
}

src/BluetoothGattService.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ std::vector<std::unique_ptr<BluetoothGattCharacteristic>> BluetoothGattService::
138138
if (p != nullptr)
139139
vector.push_back(std::move(p));
140140
}
141+
g_list_free_full(objects, g_object_unref);
141142

142143
return vector;
143144
}

src/BluetoothManager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ std::vector<std::unique_ptr<BluetoothObject>> BluetoothManager::get_objects(
169169
if (p_adapter != nullptr)
170170
vector.push_back(std::move(p_adapter));
171171
}
172+
g_list_free_full(objects, g_object_unref);
172173
return vector;
173174
}
174175

@@ -324,6 +325,7 @@ std::vector<std::unique_ptr<BluetoothAdapter>> BluetoothManager::get_adapters()
324325
if (p != nullptr)
325326
vector.push_back(std::move(p));
326327
}
328+
g_list_free_full(objects, g_object_unref);
327329

328330
return vector;
329331
}
@@ -340,6 +342,7 @@ std::vector<std::unique_ptr<BluetoothDevice>> BluetoothManager::get_devices()
340342
if (p != nullptr)
341343
vector.push_back(std::move(p));
342344
}
345+
g_list_free_full(objects, g_object_unref);
343346

344347
return vector;
345348
}
@@ -356,6 +359,7 @@ std::vector<std::unique_ptr<BluetoothGattService>> BluetoothManager::get_service
356359
if (p != nullptr)
357360
vector.push_back(std::move(p));
358361
}
362+
g_list_free_full(objects, g_object_unref);
359363

360364
return vector;
361365
}

0 commit comments

Comments
 (0)