[libs] Fix possible MD5 memory leak in Update

This commit is contained in:
Kuba Szczodrzyński
2023-08-30 11:35:11 +02:00
parent 159ffa76fd
commit 57c43ce515
2 changed files with 4 additions and 2 deletions

View File

@@ -83,7 +83,8 @@ bool UpdateClass::end(bool evenIfRemaining) {
// abort if not finished
this->errArd = UPDATE_ERROR_ABORT;
this->md5Digest = static_cast<uint8_t *>(malloc(16));
if (!this->md5Digest)
this->md5Digest = static_cast<uint8_t *>(malloc(16));
MD5Final(this->md5Digest, this->md5Ctx);
this->cleanup(/* clearError= */ evenIfRemaining);

View File

@@ -77,7 +77,8 @@ bool UpdateClass::rollBack() {
bool UpdateClass::setMD5(const char *md5) {
if (strlen(md5) != 32)
return false;
this->md5Expected = static_cast<uint8_t *>(malloc(16));
if (!this->md5Expected)
this->md5Expected = static_cast<uint8_t *>(malloc(16));
if (!this->md5Expected)
return false;
lt_xtob(md5, 32, this->md5Expected);