swscale/slice: Check slice for allocation failure

Fixes: null pointer dereference
Fixes: alloc_slice.mp4

Found-by: Rafael Dutra <rafael.dutra@cispa.de>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2021-07-07 14:05:26 +02:00
parent 40ce7aec09
commit 997f9cfc12
1 changed files with 2 additions and 1 deletions

View File

@ -288,7 +288,8 @@ int ff_init_filters(SwsContext * c)
if (!c->desc) if (!c->desc)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
c->slice = av_mallocz_array(sizeof(SwsSlice), c->numSlice); c->slice = av_mallocz_array(sizeof(SwsSlice), c->numSlice);
if (!c->slice)
goto cleanup;
res = alloc_slice(&c->slice[0], c->srcFormat, c->srcH, c->chrSrcH, c->chrSrcHSubSample, c->chrSrcVSubSample, 0); res = alloc_slice(&c->slice[0], c->srcFormat, c->srcH, c->chrSrcH, c->chrSrcHSubSample, c->chrSrcVSubSample, 0);
if (res < 0) goto cleanup; if (res < 0) goto cleanup;