Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-09-28 16:50:53 +0300
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-10-02 21:27:36 +0300
commitb7848d1b2abfbd22b29fa88522e550d4f68cfc49 (patch)
treefdf59e77a10907a99b7c672fd218ad0919cf1278 /libavcodec/rl2.c
parent98aaaf08b39fe088dc308c951a82124ec1d3b10a (diff)
avcodec/rl2: Don't presume stride to be > 0
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/rl2.c')
-rw-r--r--libavcodec/rl2.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libavcodec/rl2.c b/libavcodec/rl2.c
index 2464ad59ac..467c4913a4 100644
--- a/libavcodec/rl2.c
+++ b/libavcodec/rl2.c
@@ -65,7 +65,7 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size,
int i;
const uint8_t *back_frame = s->back_frame;
const uint8_t *in_end = in + size;
- const uint8_t *out_end = out + stride * s->avctx->height;
+ const uint8_t *out_end = out + stride * s->avctx->height - stride_adj;
uint8_t *line_end;
/** copy start of the background frame */
@@ -100,18 +100,20 @@ static void rl2_rle_decode(Rl2Context *s, const uint8_t *in, int size,
*out++ = (val == 0x80) ? *back_frame : val;
back_frame++;
if (out == line_end) {
+ if (out == out_end)
+ return;
out += stride_adj;
line_end += stride;
- if (len >= out_end - out)
- return;
}
}
}
/** copy the rest from the background frame */
if (s->back_frame) {
- while (out < out_end) {
+ while (1) {
memcpy(out, back_frame, line_end - out);
+ if (line_end == out_end)
+ break;
back_frame += line_end - out;
out = line_end + stride_adj;
line_end += stride;