summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-03-21 04:50:20 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-07-02 10:15:06 +0200
commit620cb419eecd21c6954e77f54fd09e0427bdf3e4 (patch)
treeefe1acf23e45c1a062d6f567c9f961ae4ab9880d
parent8714b82970897f30866d44fc5c1224cd0ff2634f (diff)
downloadffmpeg-620cb419eecd21c6954e77f54fd09e0427bdf3e4.tar.gz
avformat/subtitles: Don't increment packet counter prematurely
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> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 6bd8bcc2ac4c64577d964552317989e61db794d8) Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r--libavformat/subtitles.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c
index 1230e34d08..bbc4e3e356 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);