From 0dab80f7704d9b32d937fa83e1b617ab287ec6f4 Mon Sep 17 00:00:00 2001 From: thekunalsaini <43953836+thekunalsaini@users.noreply.github.com> Date: Fri, 20 Mar 2020 14:00:48 +0530 Subject: [PATCH] Dangling pointer in setManufacturerData This code sets the member _manufacturerData to an array on the stack: this causes the crash. SOLUTION:- Actually, We can pass it by reference or make an array global. --- src/utility/GAP.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utility/GAP.cpp b/src/utility/GAP.cpp index ae2e90cd..8aa4a3a0 100644 --- a/src/utility/GAP.cpp +++ b/src/utility/GAP.cpp @@ -54,7 +54,7 @@ void GAPClass::setManufacturerData(const uint8_t manufacturerData[], int manufac _manufacturerDataLength = manufacturerDataLength; } -void GAPClass::setManufacturerData(const uint16_t companyId, const uint8_t manufacturerData[], int manufacturerDataLength) +void GAPClass::setManufacturerData(const uint16_t companyId, const uint8_t &manufacturerData[], int manufacturerDataLength) { uint8_t tmpManufacturerData[manufacturerDataLength + 2]; tmpManufacturerData[0] = companyId & 0xff;