mirror of https://github.com/wolfSSL/wolfssl.git
Prevent forcezero from running on freed memory
parent
55b1ced783
commit
d2b5a9538d
|
@ -1197,6 +1197,7 @@ static int LoadKeyFile(byte** keyBuf, word32* keyBufSz,
|
||||||
if (saveBufSz < 0) {
|
if (saveBufSz < 0) {
|
||||||
saveBufSz = 0;
|
saveBufSz = 0;
|
||||||
free(saveBuf);
|
free(saveBuf);
|
||||||
|
saveBuf = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
@ -1205,8 +1206,10 @@ static int LoadKeyFile(byte** keyBuf, word32* keyBufSz,
|
||||||
ForceZero(loadBuf, (word32)fileSz);
|
ForceZero(loadBuf, (word32)fileSz);
|
||||||
free(loadBuf);
|
free(loadBuf);
|
||||||
|
|
||||||
*keyBuf = saveBuf;
|
if (saveBuf) {
|
||||||
*keyBufSz = (word32)saveBufSz;
|
*keyBuf = saveBuf;
|
||||||
|
*keyBufSz = (word32)saveBufSz;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*keyBuf = loadBuf;
|
*keyBuf = loadBuf;
|
||||||
|
|
Loading…
Reference in New Issue