[Bf-blender-cvs] [e82c5c66077] master: Fix T89868: Crash showing thumbnail of wide-aspect image
Jesse Yurkovich
noreply at git.blender.org
Sun Jul 18 02:47:17 CEST 2021
Commit: e82c5c660778b3805f50f3f2901923692c17db2a
Author: Jesse Yurkovich
Date: Sun Jul 18 10:42:52 2021 +1000
Branches: master
https://developer.blender.org/rBe82c5c660778b3805f50f3f2901923692c17db2a
Fix T89868: Crash showing thumbnail of wide-aspect image
Scaling down images could create images with a width or height of zero.
Clamp at 1 to prevent a crash, also add an assert to scaling functions.
Ref D11956
===================================================================
M source/blender/editors/render/render_preview.c
M source/blender/imbuf/intern/scaling.c
===================================================================
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index c7fa2a0ec87..5aa63ac56d8 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -1308,8 +1308,9 @@ static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect)
scaledy = (float)h;
}
- ex = (short)scaledx;
- ey = (short)scaledy;
+ /* Scaling down must never assign zero width/height, see: T89868. */
+ ex = MAX2(1, (short)scaledx);
+ ey = MAX2(1, (short)scaledy);
dx = (w - ex) / 2;
dy = (h - ey) / 2;
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index 757ec5f4b41..79c2583f983 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -1666,6 +1666,8 @@ static void scalefast_Z_ImBuf(ImBuf *ibuf, int newx, int newy)
*/
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
{
+ BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!");
+
if (ibuf == NULL) {
return false;
}
@@ -1712,6 +1714,8 @@ struct imbufRGBA {
*/
bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
{
+ BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!");
+
unsigned int *rect, *_newrect, *newrect;
struct imbufRGBA *rectf, *_newrectf, *newrectf;
int x, y;
@@ -1884,6 +1888,8 @@ static void *do_scale_thread(void *data_v)
void IMB_scaleImBuf_threaded(ImBuf *ibuf, unsigned int newx, unsigned int newy)
{
+ BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!");
+
ScaleTreadInitData init_data = {NULL};
/* prepare initialization data */
More information about the Bf-blender-cvs
mailing list