Skip to content

Fix infinite calling loop #4800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions features/FEATURE_BLE/ble/GapAdvertisingData.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,20 @@ class GapAdvertisingData
* Where the first element is the length of the field.
*/
const uint8_t* findField(DataType_t type) const {
return findField(type);
/* Scan through advertisement data */
for (uint8_t idx = 0; idx < _payloadLen; ) {
uint8_t fieldType = _payload[idx + 1];

if (fieldType == type) {
return &_payload[idx];
}

/* Advance to next field */
idx += _payload[idx] + 1;
}

/* Field not found */
return NULL;
}

private:
Expand Down Expand Up @@ -408,20 +421,7 @@ class GapAdvertisingData
* otherwise. Where the first element is the length of the field.
*/
uint8_t* findField(DataType_t type) {
/* Scan through advertisement data */
for (uint8_t idx = 0; idx < _payloadLen; ) {
uint8_t fieldType = _payload[idx + 1];

if (fieldType == type) {
return &_payload[idx];
}

/* Advance to next field */
idx += _payload[idx] + 1;
}

/* Field not found */
return NULL;
return const_cast<uint8_t*>(static_cast<const GapAdvertisingData*>(this)->findField(type));
}

/**
Expand Down