mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
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
This commit is contained in:
parent
9e64fd461a
commit
d097d35be6
2 changed files with 9 additions and 2 deletions
|
|
@ -1254,8 +1254,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;
|
||||
|
|
|
|||
|
|
@ -1620,6 +1620,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;
|
||||
}
|
||||
|
|
@ -1666,6 +1668,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;
|
||||
|
|
@ -1838,6 +1842,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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue