Commit 70b462cc authored by Peter Ross's avatar Peter Ross

Prevent memory leak introduced in r22389 in Bink demuxer: pass partial packets to decoder.

Originally committed as revision 22468 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 2b3da32f
...@@ -212,15 +212,16 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -212,15 +212,16 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
bink->current_track++; bink->current_track++;
if (audio_size >= 4) { if (audio_size >= 4) {
/* get one audio packet per track */ /* get one audio packet per track */
if ((ret = av_get_packet(pb, pkt, audio_size)) != audio_size) if ((ret = av_get_packet(pb, pkt, audio_size)) < 0)
return ret < 0 ? ret : AVERROR(EIO);; return ret;
pkt->stream_index = bink->current_track; pkt->stream_index = bink->current_track;
pkt->pts = bink->audio_pts[bink->current_track - 1]; pkt->pts = bink->audio_pts[bink->current_track - 1];
/* Each audio packet reports the number of decompressed samples /* Each audio packet reports the number of decompressed samples
(in bytes). We use this value to calcuate the audio PTS */ (in bytes). We use this value to calcuate the audio PTS */
bink->audio_pts[bink->current_track -1] += if (pkt->size >= 4)
AV_RL32(pkt->data) / (2 * s->streams[bink->current_track]->codec->channels); bink->audio_pts[bink->current_track -1] +=
AV_RL32(pkt->data) / (2 * s->streams[bink->current_track]->codec->channels);
return 0; return 0;
} else { } else {
url_fseek(pb, audio_size, SEEK_CUR); url_fseek(pb, audio_size, SEEK_CUR);
...@@ -228,9 +229,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -228,9 +229,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
} }
/* get video packet */ /* get video packet */
if ((ret = av_get_packet(pb, pkt, bink->remain_packet_size)) if ((ret = av_get_packet(pb, pkt, bink->remain_packet_size)) < 0)
!= bink->remain_packet_size) return ret;
return ret < 0 ? ret : AVERROR(EIO);
pkt->stream_index = 0; pkt->stream_index = 0;
pkt->pts = bink->video_pts++; pkt->pts = bink->video_pts++;
pkt->flags |= PKT_FLAG_KEY; pkt->flags |= PKT_FLAG_KEY;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment