Skip to content

Commit f24ba26

Browse files
alranelfacchinm
authored andcommitted
Prevent double object deletion
1 parent 1223199 commit f24ba26

9 files changed

+12
-12
lines changed

src/BLECharacteristic.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ BLECharacteristic::BLECharacteristic(const BLECharacteristic& other)
7272

7373
BLECharacteristic::~BLECharacteristic()
7474
{
75-
if (_local && _local->release() <= 0) {
75+
if (_local && _local->release() == 0) {
7676
delete _local;
7777
}
7878

79-
if (_remote && _remote->release() <= 0) {
79+
if (_remote && _remote->release() == 0) {
8080
delete _remote;
8181
}
8282
}

src/BLEDescriptor.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ BLEDescriptor::BLEDescriptor(const BLEDescriptor& other)
7272

7373
BLEDescriptor::~BLEDescriptor()
7474
{
75-
if (_local && _local->release() <= 0) {
75+
if (_local && _local->release() == 0) {
7676
delete _local;
7777
}
7878

79-
if (_remote && _remote->release() <= 0) {
79+
if (_remote && _remote->release() == 0) {
8080
delete _remote;
8181
}
8282
}

src/BLEService.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ BLEService::BLEService(const BLEService& other)
6565

6666
BLEService::~BLEService()
6767
{
68-
if (_local && _local->release() <= 0) {
68+
if (_local && _local->release() == 0) {
6969
delete _local;
7070
}
7171

72-
if (_remote && _remote->release() <= 0) {
72+
if (_remote && _remote->release() == 0) {
7373
delete _remote;
7474
}
7575
}

src/local/BLELocalCharacteristic.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ BLELocalCharacteristic::~BLELocalCharacteristic()
6262
for (unsigned int i = 0; i < descriptorCount(); i++) {
6363
BLELocalDescriptor* d = descriptor(i);
6464

65-
if (d->release() <= 0) {
65+
if (d->release() == 0) {
6666
delete d;
6767
}
6868
}

src/local/BLELocalService.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ BLELocalService::~BLELocalService()
3333
for (unsigned int i = 0; i < characteristicCount(); i++) {
3434
BLELocalCharacteristic* c = characteristic(i);
3535

36-
if (c->release() <= 0) {
36+
if (c->release() == 0) {
3737
delete c;
3838
}
3939
}

src/remote/BLERemoteCharacteristic.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ BLERemoteCharacteristic::~BLERemoteCharacteristic()
4444
for (unsigned int i = 0; i < descriptorCount(); i++) {
4545
BLERemoteDescriptor* d = descriptor(i);
4646

47-
if (d->release() <= 0) {
47+
if (d->release() == 0) {
4848
delete d;
4949
}
5050
}

src/remote/BLERemoteDevice.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void BLERemoteDevice::clearServices()
5050
for (unsigned int i = 0; i < serviceCount(); i++) {
5151
BLERemoteService* s = service(i);
5252

53-
if (s->release() <= 0) {
53+
if (s->release() == 0) {
5454
delete s;
5555
}
5656
}

src/remote/BLERemoteService.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ BLERemoteService::~BLERemoteService()
3131
for (unsigned int i = 0; i < characteristicCount(); i++) {
3232
BLERemoteCharacteristic* c = characteristic(i);
3333

34-
if (c->release() <= 0) {
34+
if (c->release() == 0) {
3535
delete c;
3636
}
3737
}

src/utility/GATT.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void GATTClass::clearAttributes()
179179
for (unsigned int i = 0; i < attributeCount(); i++) {
180180
BLELocalAttribute* a = attribute(i);
181181

182-
if (a->release() <= 0) {
182+
if (a->release() == 0) {
183183
delete a;
184184
}
185185
}

0 commit comments

Comments
 (0)