swscale/swscale: Fix dereference of stride array before null check

Fixes: CID1396263
Fixes: CID1396271

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2016-12-23 21:14:59 +01:00
parent 6d579d7c1b
commit 03ce71e4a1
1 changed files with 7 additions and 4 deletions

View File

@ -762,10 +762,8 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
uint8_t *rgb0_tmp = NULL; uint8_t *rgb0_tmp = NULL;
int macro_height = isBayer(c->srcFormat) ? 2 : (1 << c->chrSrcVSubSample); int macro_height = isBayer(c->srcFormat) ? 2 : (1 << c->chrSrcVSubSample);
// copy strides, so they can safely be modified // copy strides, so they can safely be modified
int srcStride2[4] = { srcStride[0], srcStride[1], srcStride[2], int srcStride2[4];
srcStride[3] }; int dstStride2[4];
int dstStride2[4] = { dstStride[0], dstStride[1], dstStride[2],
dstStride[3] };
int srcSliceY_internal = srcSliceY; int srcSliceY_internal = srcSliceY;
if (!srcStride || !dstStride || !dst || !srcSlice) { if (!srcStride || !dstStride || !dst || !srcSlice) {
@ -773,6 +771,11 @@ int attribute_align_arg sws_scale(struct SwsContext *c,
return 0; return 0;
} }
for (i=0; i<4; i++) {
srcStride2[i] = srcStride[i];
dstStride2[i] = dstStride[i];
}
if ((srcSliceY & (macro_height-1)) || if ((srcSliceY & (macro_height-1)) ||
((srcSliceH& (macro_height-1)) && srcSliceY + srcSliceH != c->srcH) || ((srcSliceH& (macro_height-1)) && srcSliceY + srcSliceH != c->srcH) ||
srcSliceY + srcSliceH > c->srcH) { srcSliceY + srcSliceH > c->srcH) {