[FFmpeg-cvslog] msnwc_tcp: Correctly report failure

Luca Barbato git at videolan.org
Tue Nov 10 17:56:38 CET 2015


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Sun Nov  1 04:07:43 2015 +0100| [4dfbc7a7559ccab666a8fd39de4224eb4b02c768] | committer: Luca Barbato

msnwc_tcp: Correctly report failure

And prevent a memory leak

CC: libav-stable at libav.org

Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4dfbc7a7559ccab666a8fd39de4224eb4b02c768
---

 libavformat/msnwc_tcp.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/msnwc_tcp.c b/libavformat/msnwc_tcp.c
index b6d30fe..afdcac4 100644
--- a/libavformat/msnwc_tcp.c
+++ b/libavformat/msnwc_tcp.c
@@ -104,6 +104,7 @@ static int msnwc_tcp_read_packet(AVFormatContext *ctx, AVPacket *pkt)
     AVIOContext *pb = ctx->pb;
     uint16_t keyframe;
     uint32_t size, timestamp;
+    int ret;
 
     avio_skip(pb, 1); /* one byte has been read ahead */
     avio_skip(pb, 2);
@@ -114,8 +115,11 @@ static int msnwc_tcp_read_packet(AVFormatContext *ctx, AVPacket *pkt)
     avio_skip(pb, 4);
     timestamp = avio_rl32(pb);
 
-    if(!size || av_get_packet(pb, pkt, size) != size)
-        return -1;
+    if (!size)
+        return AVERROR_INVALIDDATA;
+
+    if ((ret = av_get_packet(pb, pkt, size)) < 0)
+        return ret;
 
     avio_skip(pb, 1); /* Read ahead one byte of struct size like read_header */
 



More information about the ffmpeg-cvslog mailing list