[Bf-blender-cvs] [77ddcc47172] master: ImBuf: replace exit(1) with assert when writing IRIS images

Campbell Barton noreply at git.blender.org
Tue May 17 02:54:42 CEST 2022


Commit: 77ddcc471721194531834786c010b9e603cb18d8
Author: Campbell Barton
Date:   Tue May 17 10:50:21 2022 +1000
Branches: master
https://developer.blender.org/rB77ddcc471721194531834786c010b9e603cb18d8

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.

===================================================================

M	source/blender/imbuf/intern/iris.c

===================================================================

diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index c3d940d85be..a8150fd1648 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -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;



More information about the Bf-blender-cvs mailing list