@@ -170,7 +170,7 @@ bool pointperfectProvisionDevice()
170
170
bluetoothStop (); // Free heap before starting secure client (requires ~70KB)
171
171
172
172
DynamicJsonDocument * jsonZtp = nullptr ;
173
- char * tempHolder = nullptr ;
173
+ char *tempHolderPtr = nullptr ;
174
174
bool retVal = false ;
175
175
176
176
do
@@ -248,6 +248,7 @@ bool pointperfectProvisionDevice()
248
248
systemPrintln (" ERROR - Failed to allocate jsonZtp!\r\n " );
249
249
break ;
250
250
}
251
+
251
252
DeserializationError error = deserializeJson (*jsonZtp, response);
252
253
if (DeserializationError::Ok != error)
253
254
{
@@ -256,21 +257,22 @@ bool pointperfectProvisionDevice()
256
257
}
257
258
else
258
259
{
259
- tempHolder = (char *)malloc (2000 );
260
- if (!tempHolder)
260
+ const int tempHolderSize = 2000 ;
261
+ tempHolderPtr = (char *)malloc (tempHolderSize);
262
+ if (!tempHolderPtr)
261
263
{
262
- systemPrintln (" ERROR - Failed to allocate tempHolder buffer!\r\n " );
264
+ systemPrintln (" ERROR - Failed to allocate tempHolderPtr buffer!\r\n " );
263
265
break ;
264
266
}
265
- strncpy (tempHolder , (const char *)((*jsonZtp)[" certificate" ]), sizeof (tempHolder) - 1 );
266
- // systemPrintf ("len of PrivateCert: %d\r\n ", strlen(tempHolder ));
267
- // systemPrintf ("privateCert: %s\r\n ", tempHolder );
268
- recordFile (" certificate" , tempHolder , strlen (tempHolder ));
267
+ strncpy (tempHolderPtr , (const char *)((*jsonZtp)[" certificate" ]), tempHolderSize - 1 );
268
+ // log_d ("len of PrivateCert: %d", strlen(tempHolderPtr ));
269
+ // log_d ("privateCert: %s", tempHolderPtr );
270
+ recordFile (" certificate" , tempHolderPtr , strlen (tempHolderPtr ));
269
271
270
- strncpy (tempHolder , (const char *)((*jsonZtp)[" privateKey" ]), sizeof (tempHolder) - 1 );
271
- // systemPrintf ("len of privateKey: %d\r\n ", strlen(tempHolder ));
272
- // systemPrintf ("privateKey: %s\r\n ", tempHolder );
273
- recordFile (" privateKey" , tempHolder , strlen (tempHolder ));
272
+ strncpy (tempHolderPtr , (const char *)((*jsonZtp)[" privateKey" ]), tempHolderSize - 1 );
273
+ // log_d ("len of privateKey: %d", strlen(tempHolderPtr ));
274
+ // log_d ("privateKey: %s", tempHolderPtr );
275
+ recordFile (" privateKey" , tempHolderPtr , strlen (tempHolderPtr ));
274
276
275
277
strcpy (settings.pointPerfectClientID , (const char *)((*jsonZtp)[" clientId" ]));
276
278
strcpy (settings.pointPerfectBrokerHost , (const char *)((*jsonZtp)[" brokerHost" ]));
@@ -293,8 +295,8 @@ bool pointperfectProvisionDevice()
293
295
} while (0 );
294
296
295
297
// Free the allocated buffers
296
- if (tempHolder )
297
- free (tempHolder );
298
+ if (tempHolderPtr )
299
+ free (tempHolderPtr );
298
300
if (jsonZtp)
299
301
delete jsonZtp;
300
302
0 commit comments