mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Remove memory leak on multiple calls to initCertStore (#7021)
In some cases, `initCertStore` may need to be called multiple times (i.e. to update certs w/oa reboot). In that case, the saved file names leaked when the new ones were `malloc()`'d. Fix by freeing the old strings, if present.
This commit is contained in:
parent
b930c4c3e6
commit
00440cd84a
@ -82,6 +82,10 @@ int CertStore::initCertStore(FS &fs, const char *indexFileName, const char *data
|
|||||||
|
|
||||||
_fs = &fs;
|
_fs = &fs;
|
||||||
|
|
||||||
|
// In case initCertStore called multiple times, don't leak old filenames
|
||||||
|
free(_indexName);
|
||||||
|
free(_dataName);
|
||||||
|
|
||||||
// No strdup_P, so manually do it
|
// No strdup_P, so manually do it
|
||||||
_indexName = (char *)malloc(strlen_P(indexFileName) + 1);
|
_indexName = (char *)malloc(strlen_P(indexFileName) + 1);
|
||||||
_dataName = (char *)malloc(strlen_P(dataFileName) + 1);
|
_dataName = (char *)malloc(strlen_P(dataFileName) + 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user