[FFmpeg-devel] [PATCH 09/22] lavfhttpd.c: Free client context if allocated but an error occured

Stephan Holljes klaxa1337 at googlemail.com
Fri Jun 1 01:24:02 EEST 2018


Signed-off-by: Stephan Holljes <klaxa1337 at googlemail.com>
---
 lavfhttpd.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lavfhttpd.c b/lavfhttpd.c
index 5488e14..d094d65 100644
--- a/lavfhttpd.c
+++ b/lavfhttpd.c
@@ -66,10 +66,13 @@ int lavfhttpd_accept(void *server, struct HTTPClient **client, int reply_code)
     int reply_code2 = reply_code;
     char *method, *resource;
     if ((ret = avio_accept(server_ctx, &client_ctx)) < 0) {
-        if (ret == AVERROR(ETIMEDOUT))
+        if (ret == AVERROR(ETIMEDOUT)) {
             return HTTPD_LISTEN_TIMEOUT;
-        else
+        } else {
+            if (client_ctx)
+                avio_context_free(&client_ctx);
             return HTTPD_OTHER_ERROR;
+        }
     }
     client_ctx->seekable = 0;
     ret2 = HTTPD_OK;
-- 
2.16.2



More information about the ffmpeg-devel mailing list