Skip to content

Commit

Permalink
Merge pull request #2332 from particle-iot/bug/ble_possible_memory_leak
Browse files Browse the repository at this point in the history
Free malloc'ed memory
  • Loading branch information
mgolu authored Jun 28, 2021
2 parents ae01e6a + 124d24b commit b611090
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions wiring/src/spark_wiring_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,11 @@ class BleScanDelegator {
}
if (srLen == filterCustomDatalen) {
uint8_t* buf = (uint8_t*)malloc(srLen);
SCOPE_GUARD({
if (buf) {
free(buf);
}
});
if (!buf) {
LOG(ERROR, "Failed to allocate memory!");
return false;
Expand All @@ -2455,6 +2460,11 @@ class BleScanDelegator {
}
if (advLen == filterCustomDatalen) {
uint8_t* buf = (uint8_t*)malloc(advLen);
SCOPE_GUARD({
if (buf) {
free(buf);
}
});
if (!buf) {
LOG(ERROR, "Failed to allocate memory!");
return false;
Expand Down

0 comments on commit b611090

Please sign in to comment.