[FFmpeg-cvslog] avcodec/mss12: Don't apply non-zero offset to null pointer
Andreas Rheinhardt
git at videolan.org
Thu Apr 1 17:12:20 EEST 2021
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Fri Mar 26 14:40:40 2021 +0100| [8429661db86b1e76bcae9d8381389098e57417de] | committer: Andreas Rheinhardt
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 at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8429661db86b1e76bcae9d8381389098e57417de
---
libavcodec/mss12.c | 17 ++++++++++-------
1 file 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,
More information about the ffmpeg-cvslog
mailing list