diff mbox series

[FFmpeg-devel,1/2] avformat/libzmq: Check return of zmq_setsockopt

Message ID 20200111042526.32351-1-andriy.gelman@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/2] avformat/libzmq: Check return of zmq_setsockopt
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andriy Gelman Jan. 11, 2020, 4:25 a.m. UTC
From: Andriy Gelman <andriy.gelman@gmail.com>

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
---
 libavformat/libzmq.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavformat/libzmq.c b/libavformat/libzmq.c
index d86488293ff..2df55542c7e 100644
--- a/libavformat/libzmq.c
+++ b/libavformat/libzmq.c
@@ -123,7 +123,14 @@  static int zmq_proto_open(URLContext *h, const char *uri, int flags)
             return AVERROR_EXTERNAL;
         }
 
-        zmq_setsockopt(s->socket, ZMQ_SUBSCRIBE, "", 0);
+        ret = zmq_setsockopt(s->socket, ZMQ_SUBSCRIBE, "", 0);
+        if (ret == -1) {
+            av_log(h, AV_LOG_ERROR, "Error occured during zmq_setsockopt(): %s\n", ZMQ_STRERROR);
+            zmq_close(s->socket);
+            zmq_ctx_term(s->context);
+            return AVERROR_EXTERNAL;
+        }
+
         ret = zmq_connect(s->socket, uri);
         if (ret == -1) {
             av_log(h, AV_LOG_ERROR, "Error occured during zmq_connect(): %s\n", ZMQ_STRERROR);