From 117aeaa15d6a4ebb26b930304d176e6893a36742 Mon Sep 17 00:00:00 2001 From: cpq Date: Sun, 3 Jan 2021 09:39:46 +0000 Subject: [PATCH] Fix fd leak for cached static files --- mongoose.c | 1 + src/http.c | 1 + 2 files changed, 2 insertions(+) diff --git a/mongoose.c b/mongoose.c index a7dc9c10..a0ac0699 100644 --- a/mongoose.c +++ b/mongoose.c @@ -786,6 +786,7 @@ void mg_http_serve_file(struct mg_connection *c, struct mg_http_message *hm, mg_http_etag(etag, sizeof(etag), &st) != etag) { mg_http_reply(c, 404, "", "%s", "Not found\n"); } else if (inm != NULL && mg_vcasecmp(inm, etag) == 0) { + fclose(fp); mg_printf(c, "HTTP/1.1 304 Not Modified\r\nContent-Length: 0\r\n\r\n"); } else { mg_printf(c, diff --git a/src/http.c b/src/http.c index 364cf956..7cb22835 100644 --- a/src/http.c +++ b/src/http.c @@ -372,6 +372,7 @@ void mg_http_serve_file(struct mg_connection *c, struct mg_http_message *hm, mg_http_etag(etag, sizeof(etag), &st) != etag) { mg_http_reply(c, 404, "", "%s", "Not found\n"); } else if (inm != NULL && mg_vcasecmp(inm, etag) == 0) { + fclose(fp); mg_printf(c, "HTTP/1.1 304 Not Modified\r\nContent-Length: 0\r\n\r\n"); } else { mg_printf(c,