[FFmpeg-devel] [PATCH 2/2] lavf/vobsub: free index pseudo-packet.
Clément Bœsch
ubitux at gmail.com
Wed Mar 20 19:21:15 CET 2013
On Wed, Mar 20, 2013 at 11:15:08AM +0100, Nicolas George wrote:
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavformat/mpeg.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
> index 5387b09..f36f0db 100644
> --- a/libavformat/mpeg.c
> +++ b/libavformat/mpeg.c
> @@ -805,6 +805,8 @@ end:
> return ret;
> }
>
> +#define FAIL(r) do { ret = r; goto fail; } while (0)
> +
> static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt)
> {
> MpegDemuxContext *vobsub = s->priv_data;
> @@ -838,7 +840,7 @@ static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt)
>
> ret = mpegps_read_pes_header(vobsub->sub_ctx, NULL, &startcode, &pts, &dts);
> if (ret < 0)
> - return ret;
> + FAIL(ret);
> to_read = ret & 0xffff;
>
> /* this prevents reads above the current packet */
> @@ -855,7 +857,7 @@ static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt)
>
> ret = av_grow_packet(pkt, to_read);
> if (ret < 0)
> - return ret;
> + FAIL(ret);
>
> n = avio_read(pb, pkt->data + (pkt->size - to_read), to_read);
> if (n < to_read)
> @@ -870,7 +872,12 @@ static int vobsub_read_packet(AVFormatContext *s, AVPacket *pkt)
> pkt->pos = idx_pkt.pos;
> pkt->stream_index = idx_pkt.stream_index;
>
> + av_free_packet(&idx_pkt);
> return 0;
> +
> +fail:
> + av_free_packet(&idx_pkt);
> + return ret;
> }
>
That looks correct, thanks; I wonder why it wasn't detected earlier (or
maybe it was?).
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130320/ad369728/attachment.asc>
More information about the ffmpeg-devel
mailing list