From ba685dbe48e350944d00b588eb6d0e2868e3803d Mon Sep 17 00:00:00 2001 From: yhirose Date: Sun, 10 May 2020 20:45:57 -0400 Subject: [PATCH] Fixed potential infinite loop with content receiver --- httplib.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httplib.h b/httplib.h index f8b1074..58a941c 100644 --- a/httplib.h +++ b/httplib.h @@ -2083,7 +2083,9 @@ inline ssize_t write_content(Stream &strm, ContentProvider content_provider, written_length = strm.write(d, l); }; data_sink.done = [&](void) { written_length = -1; }; - data_sink.is_writable = [&](void) { return strm.is_writable(); }; + data_sink.is_writable = [&](void) { + return strm.is_writable() && written_length >= 0; + }; content_provider(offset, end_offset - offset, data_sink); if (written_length < 0) { return written_length; }