aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mss12.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2021-03-26 14:40:40 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-04-01 14:44:40 +0200
commit8429661db86b1e76bcae9d8381389098e57417de (patch)
tree69d28e2da1b8e8f2bf827223fe35d7388a24a605 /libavcodec/mss12.c
parentdd9cbd1cc31e72ad9f11d10d086a46d339a924ca (diff)
downloadffmpeg-8429661db86b1e76bcae9d8381389098e57417de.tar.gz
avcodec/mss12: Don't apply non-zero offset to null pointer
Affected the FATE tests mss2-wmv and mss1-pal. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/mss12.c')
-rw-r--r--libavcodec/mss12.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libavcodec/mss12.c b/libavcodec/mss12.c
index 5a5bd9a91b..5afdaacfe6 100644
--- a/libavcodec/mss12.c
+++ b/libavcodec/mss12.c
@@ -291,14 +291,15 @@ static int decode_pixel_in_context(ArithCoder *acoder, PixContext *pctx,
return decode_pixel(acoder, pctx, ref_pix, nlen, 1);
}
-static int decode_region(ArithCoder *acoder, uint8_t *dst, uint8_t *rgb_pic,
+static int decode_region(ArithCoder *acoder, uint8_t *dst, uint8_t *rgb_dst,
int x, int y, int width, int height, ptrdiff_t stride,
ptrdiff_t rgb_stride, PixContext *pctx,
const uint32_t *pal)
{
int i, j, p;
- uint8_t *rgb_dst = rgb_pic + x * 3 + y * rgb_stride;
+ rgb_stride = rgb_dst ? rgb_stride : 0;
+ rgb_dst = rgb_dst ? rgb_dst + x * 3 + y * rgb_stride : NULL;
dst += x + y * stride;
for (j = 0; j < height; j++) {
@@ -312,11 +313,11 @@ static int decode_region(ArithCoder *acoder, uint8_t *dst, uint8_t *rgb_pic,
return p;
dst[i] = p;
- if (rgb_pic)
+ if (rgb_dst)
AV_WB24(rgb_dst + i * 3, pal[p]);
}
dst += stride;
- rgb_dst += rgb_stride;
+ rgb_dst = FF_PTR_ADD(rgb_dst, rgb_stride);
}
return 0;
@@ -476,17 +477,19 @@ static int decode_region_intra(SliceContext *sc, ArithCoder *acoder,
ptrdiff_t stride = c->pal_stride;
ptrdiff_t rgb_stride = c->rgb_stride;
uint8_t *dst = c->pal_pic + x + y * stride;
- uint8_t *rgb_dst = c->rgb_pic + x * 3 + y * rgb_stride;
+ uint8_t *rgb_dst = c->rgb_pic ? c->rgb_pic + x * 3 + y * rgb_stride : NULL;
pix = decode_pixel(acoder, &sc->intra_pix_ctx, NULL, 0, 0);
if (pix < 0)
return pix;
rgb_pix = c->pal[pix];
- for (i = 0; i < height; i++, dst += stride, rgb_dst += rgb_stride) {
+ for (i = 0; i < height; i++, dst += stride) {
memset(dst, pix, width);
- if (c->rgb_pic)
+ if (rgb_dst) {
for (j = 0; j < width * 3; j += 3)
AV_WB24(rgb_dst + j, rgb_pix);
+ rgb_dst += rgb_stride;
+ }
}
} else {
return decode_region(acoder, c->pal_pic, c->rgb_pic,