Properly close files served by debug HTTP server.

This commit is contained in:
Fabio Alessandrelli 2020-01-14 15:06:53 +01:00
parent 1798496ea7
commit 14a58560e1

View file

@ -119,7 +119,10 @@ public:
s += "\r\n"; s += "\r\n";
CharString cs = s.utf8(); CharString cs = s.utf8();
Error err = connection->put_data((const uint8_t *)cs.get_data(), cs.size() - 1); Error err = connection->put_data((const uint8_t *)cs.get_data(), cs.size() - 1);
ERR_FAIL_COND(err != OK); if (err != OK) {
memdelete(f);
ERR_FAIL();
}
while (true) { while (true) {
uint8_t bytes[4096]; uint8_t bytes[4096];
@ -128,8 +131,12 @@ public:
break; break;
} }
err = connection->put_data(bytes, read); err = connection->put_data(bytes, read);
ERR_FAIL_COND(err != OK); if (err != OK) {
memdelete(f);
ERR_FAIL();
}
} }
memdelete(f);
} }
void poll() { void poll() {