Fixed issue-3153 - Allocating enough memory to construct the entire UUID as a String. (#3297)

This commit is contained in:
William Ferguson 2019-09-30 06:03:48 +10:00 committed by Me No Dev
parent 9bbd720d4c
commit 5bff89f0be

View File

@ -367,7 +367,7 @@ std::string BLEUUID::toString() {
// //
// UUID string format: // UUID string format:
// AABBCCDD-EEFF-GGHH-IIJJ-KKLLMMNNOOPP // AABBCCDD-EEFF-GGHH-IIJJ-KKLLMMNNOOPP
auto size = 35; auto size = 37; // 32 for UUID data, 4 for '-' delimiters and one for a terminator == 37 chars
char *hex = (char *)malloc(size); char *hex = (char *)malloc(size);
snprintf(hex, size, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", snprintf(hex, size, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
m_uuid.uuid.uuid128[15], m_uuid.uuid.uuid128[14], m_uuid.uuid.uuid128[15], m_uuid.uuid.uuid128[14],