From: Mikael Magnusson Date: Fri, 28 Mar 2008 20:01:46 +0000 (+0100) Subject: dana pls look at this. When icons had a very small aspect ratio, we crashed, don't. X-Git-Tag: mikabox-3.4.7.2~46 X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=25aa4677b0689e657ef73830dd2590b0daa86182;p=mikachu%2Fopenbox.git dana pls look at this. When icons had a very small aspect ratio, we crashed, don't. If this is the right fix, either 1) tell me or 2) remove the XXX and change this message :). --- diff --git a/render/image.c b/render/image.c index 6b79c454..0ab21374 100644 --- a/render/image.c +++ b/render/image.c @@ -124,6 +124,12 @@ static RrImagePic* ResizeImage(RrPixel32 *src, gulong ratioX, ratioY; gulong aspectW, aspectH; + /* XXX should these variables be ensured to not be zero in the callers? */ + srcW = srcW ? srcW : 1; + srcH = srcH ? srcH : 1; + dstW = dstW ? dstW : 1; + dstH = dstH ? dstH : 1; + /* keep the aspect ratio */ aspectW = dstW; aspectH = (gint)(dstW * ((gdouble)srcH / srcW)); @@ -131,11 +137,11 @@ static RrImagePic* ResizeImage(RrPixel32 *src, aspectH = dstH; aspectW = (gint)(dstH * ((gdouble)srcW / srcH)); } - dstW = aspectW; - dstH = aspectH; + dstW = aspectW ? aspectW : 1; + dstH = aspectH ? aspectH : 1; if (srcW == dstW && srcH == dstH) - return NULL; /* no scaling needed ! */ + return NULL; /* no scaling needed! */ dststart = dst = g_new(RrPixel32, dstW * dstH);