diff mbox series

[FFmpeg-devel] avformat/subtitles: Don't increment packet counter prematurely

Message ID 20200321035020.1483-1-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel] avformat/subtitles: Don't increment packet counter prematurely | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt March 21, 2020, 3:50 a.m. UTC
Do it only if the packet has been successfully allocated in
av_new_packet() -- otherwise on error a completely uninitialized packet
would be unreferenced later.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/subtitles.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer March 22, 2020, 12:04 p.m. UTC | #1
On Sat, Mar 21, 2020 at 04:50:20AM +0100, Andreas Rheinhardt wrote:
> Do it only if the packet has been successfully allocated in
> av_new_packet() -- otherwise on error a completely uninitialized packet
> would be unreferenced later.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/subtitles.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c
index 172da5de2b..ad7f68938e 100644
--- a/libavformat/subtitles.c
+++ b/libavformat/subtitles.c
@@ -132,9 +132,10 @@  AVPacket *ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q,
         if (!subs)
             return NULL;
         q->subs = subs;
-        sub = &subs[q->nb_subs++];
+        sub = &subs[q->nb_subs];
         if (av_new_packet(sub, len) < 0)
             return NULL;
+        q->nb_subs++;
         sub->flags |= AV_PKT_FLAG_KEY;
         sub->pts = sub->dts = 0;
         memcpy(sub->data, event, len);