Browse Source

msnwc_tcp: Correctly report failure

And prevent a memory leak

CC: libav-stable@libav.org

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
tags/n3.0
Luca Barbato 10 years ago
parent
commit
4dfbc7a755
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      libavformat/msnwc_tcp.c

+ 6
- 2
libavformat/msnwc_tcp.c View File

@@ -104,6 +104,7 @@ static int msnwc_tcp_read_packet(AVFormatContext *ctx, AVPacket *pkt)
AVIOContext *pb = ctx->pb; AVIOContext *pb = ctx->pb;
uint16_t keyframe; uint16_t keyframe;
uint32_t size, timestamp; uint32_t size, timestamp;
int ret;


avio_skip(pb, 1); /* one byte has been read ahead */ avio_skip(pb, 1); /* one byte has been read ahead */
avio_skip(pb, 2); avio_skip(pb, 2);
@@ -114,8 +115,11 @@ static int msnwc_tcp_read_packet(AVFormatContext *ctx, AVPacket *pkt)
avio_skip(pb, 4); avio_skip(pb, 4);
timestamp = avio_rl32(pb); 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 */ avio_skip(pb, 1); /* Read ahead one byte of struct size like read_header */




Loading…
Cancel
Save