Skip to content

Commit ab43135

Browse files
thekurtovich2zero
authored andcommitted
Fix NimBLEUtils::dataToHexString returned string, must resize before modifying.
1 parent 84f4d4f commit ab43135

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/NimBLEUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ const char* NimBLEUtils::gapEventToString(uint8_t eventType) {
500500
std::string NimBLEUtils::dataToHexString(const uint8_t* source, uint8_t length) {
501501
constexpr char hexmap[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
502502
std::string str{};
503-
str.reserve(length * 2 + 1);
503+
str.resize(length * 2);
504504

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

0 commit comments

Comments
 (0)