Skip to content

Commit

Permalink
Fix NimBLEUtils::dataToHexString returned string, must resize before …
Browse files Browse the repository at this point in the history
…modifying.
  • Loading branch information
thekurtovic authored and h2zero committed Nov 14, 2024
1 parent ba783a0 commit 64d1492
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/NimBLEUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ const char* NimBLEUtils::gapEventToString(uint8_t eventType) {
std::string NimBLEUtils::dataToHexString(const uint8_t* source, uint8_t length) {
constexpr char hexmap[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
std::string str{};
str.reserve(length * 2 + 1);
str.resize(length << 1);

for (uint8_t i = 0; i < length; i++) {
str[2 * i] = hexmap[(source[i] & 0xF0) >> 4];
Expand Down

0 comments on commit 64d1492

Please sign in to comment.