ImBuf: replace exit(1) with assert when writing IRIS images

In this case memory past the buffer bounds would have been written,
potentially crashing. Replace the check with an assert since this
should never happen.

Also don't call exit as failing to write a file shouldn't exit Blender.
This commit is contained in:
Campbell Barton 2022-05-17 10:50:21 +10:00
parent 7bbf101082
commit 77ddcc4717
1 changed files with 3 additions and 4 deletions

View File

@ -854,10 +854,9 @@ static bool output_iris(const char *filepath,
len = compressrow((const uchar *)zptr, rlebuf, CHANOFFSET(z - 4), xsize);
}
}
if (len > rlebuflen) {
fprintf(stderr, "output_iris: rlebuf is too small - bad poop\n");
exit(1);
}
BLI_assert_msg(len <= rlebuflen, "The length calculated for 'rlebuflen' was too small!");
goodwrite *= fwrite(rlebuf, len, 1, outf);
starttab[y + z * ysize] = pos;
lengthtab[y + z * ysize] = len;