forked from HandBrake/HandBrake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA18-dvdsubdec-fix-processing-of-partial-packets.patch
49 lines (41 loc) · 1.71 KB
/
A18-dvdsubdec-fix-processing-of-partial-packets.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From b5846bbdf2bea0ec40ab68fbb5440e17a9390f65 Mon Sep 17 00:00:00 2001
From: John Stebbins <[email protected]>
Date: Wed, 11 Dec 2019 14:10:09 -0800
Subject: [PATCH] dvdsubdec: fix processing of partial packets
Wait for a complete dvd subtitle before processing.
If the input packet is large enough to start processing, but does not
contain complete data, unfinished results are emitted and the following
input packet causes an error because the stream is no longer in sync
with the decoder.
---
libavcodec/dvdsubdec.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index 741ea9fd1e..c0c9962bad 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -232,7 +232,7 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
int64_t offset1, offset2;
if (buf_size < 10)
- return -1;
+ return AVERROR(EAGAIN);
if (AV_RB16(buf) == 0) { /* HD subpicture with 4-byte offsets */
big_offsets = 1;
@@ -247,12 +247,12 @@ static int decode_dvd_subtitles(DVDSubContext *ctx, AVSubtitle *sub_header,
size = READ_OFFSET(buf + (big_offsets ? 2 : 0));
cmd_pos = READ_OFFSET(buf + cmd_pos);
- if (cmd_pos < 0 || cmd_pos > buf_size - 2 - offset_size) {
- if (cmd_pos > size) {
- av_log(ctx, AV_LOG_ERROR, "Discarding invalid packet\n");
- return 0;
- }
+ if (buf_size < size)
return AVERROR(EAGAIN);
+
+ if (cmd_pos < 0 || cmd_pos > size) {
+ av_log(ctx, AV_LOG_ERROR, "Discarding invalid packet\n");
+ return AVERROR_INVALIDDATA;
}
while (cmd_pos > 0 && cmd_pos < buf_size - 2 - offset_size) {
--
2.23.0