[Bf-blender-cvs] [0de54a9cfea] blender-v2.83-release: Fix T89868: Crash showing thumbnail of wide-aspect image
Jesse Yurkovich
noreply at git.blender.org
Mon Jul 26 09:59:21 CEST 2021
Commit: 0de54a9cfea5a981bfa9fa6ef2fed25a0c0086cc
Author: Jesse Yurkovich
Date: Sun Jul 18 10:42:52 2021 +1000
Branches: blender-v2.83-release
https://developer.blender.org/rB0de54a9cfea5a981bfa9fa6ef2fed25a0c0086cc
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 0432057bb47..28cb5ac07a8 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -1042,8 +1042,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 95f720a9d16..bab37f72d79 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -1618,6 +1618,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(newx > 0 && newy > 0);
+
if (ibuf == NULL) {
return false;
}
@@ -1664,6 +1666,8 @@ struct imbufRGBA {
*/
bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
{
+ BLI_assert(newx > 0 && newy > 0);
+
unsigned int *rect, *_newrect, *newrect;
struct imbufRGBA *rectf, *_newrectf, *newrectf;
int x, y;
@@ -1836,6 +1840,8 @@ static void *do_scale_thread(void *data_v)
void IMB_scaleImBuf_threaded(ImBuf *ibuf, unsigned int newx, unsigned int newy)
{
+ BLI_assert(newx > 0 && newy > 0);
+
ScaleTreadInitData init_data = {NULL};
/* prepare initialization data */
More information about the Bf-blender-cvs
mailing list