Skip to content

Commit b976d00

Browse files
committed
fix: deallocate inflator's mem on update begin failure
1 parent 59effe5 commit b976d00

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/flashz-http.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,18 @@ fz_http_err_t FlashZhttp::_http_get(const char* url, int imgtype){
207207
ESP_LOGI(TAG, "Updating %s, input size:%u, mode_z:%u, magic: %02X", (imgtype == U_FLASH)? "FW" : "FS", len, mode_z, stream->peek());
208208

209209
if (!(mode_z ? FlashZ::getInstance().beginz(fwsize, imgtype) : FlashZ::getInstance().begin(fwsize, imgtype))){
210+
FlashZ::getInstance().abortz();
210211
ESP_LOGW(TAG, "Failed to start Update");
211212
return fz_http_err_t::bad_start;
212213
}
213214

214215
size_t wrt = mode_z ? FlashZ::getInstance().writezStream(*stream, len) : FlashZ::getInstance().writeStream(*stream);
216+
http.end();
217+
stream = nullptr;
215218

216219
if (wrt != len){
217220
FlashZ::getInstance().abortz();
218221
ESP_LOGE(TAG, "UPD failed, wrt:%d of %d\n", wrt, len);
219-
http.end();
220222
return fz_http_err_t::write_err;
221223
} else {
222224
if(FlashZ::getInstance().endz()){
@@ -226,8 +228,6 @@ fz_http_err_t FlashZhttp::_http_get(const char* url, int imgtype){
226228
}
227229
}
228230

229-
http.end();
230-
231231
if (rst_timeout){
232232
if (t)
233233
t->detach();

0 commit comments

Comments
 (0)