X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fmpc.c;h=85036cd118d545039f4ddfd6dce9840022e6b7bd;hb=3004ef1b1b1bcd6bec4ad3509662ab1a4b644149;hp=af333746e3a96c9714d8c8b8850597c2e87474cb;hpb=217ad40aef9eeeff4e805dec3e980fb16aec3345;p=ffmpeg diff --git a/libavformat/mpc.c b/libavformat/mpc.c index af333746e3a..85036cd118d 100644 --- a/libavformat/mpc.c +++ b/libavformat/mpc.c @@ -45,7 +45,7 @@ typedef struct MPCContext { int frames_noted; } MPCContext; -static int mpc_probe(AVProbeData *p) +static int mpc_probe(const AVProbeData *p) { const uint8_t *d = p->buf; if (d[0] == 'M' && d[1] == 'P' && d[2] == '+' && (d[3] == 0x17 || d[3] == 0x7)) @@ -88,7 +88,7 @@ static int mpc_read_header(AVFormatContext *s) st = avformat_new_stream(s, NULL); if (!st) - return AVERROR(ENOMEM); + goto mem_error; st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->codec_id = AV_CODEC_ID_MUSEPACK7; st->codecpar->channels = 2; @@ -96,7 +96,7 @@ static int mpc_read_header(AVFormatContext *s) st->codecpar->bits_per_coded_sample = 16; if (ff_get_extradata(s, st->codecpar, s->pb, 16) < 0) - return AVERROR(ENOMEM); + goto mem_error; st->codecpar->sample_rate = mpc_rate[st->codecpar->extradata[2] & 3]; avpriv_set_pts_info(st, 32, MPC_FRAMESIZE, st->codecpar->sample_rate); /* scan for seekpoints */ @@ -113,6 +113,9 @@ static int mpc_read_header(AVFormatContext *s) } return 0; +mem_error: + av_freep(&c->frames); + return AVERROR(ENOMEM); } static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) @@ -166,7 +169,6 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) if(c->curbits) avio_seek(s->pb, -4, SEEK_CUR); if(ret < size){ - av_packet_unref(pkt); return ret < 0 ? ret : AVERROR(EIO); } pkt->size = ret + 4;