File Bug1120502-add_cast_to_prevent_overflow.patch of Package libcaca.23161

Author: Josef Möllers <jmoellers@suse.de>
Index: libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/dither.c
===================================================================
--- libcaca-da28e9684ef445ac8d42745644336b8a75c01855.orig/caca/dither.c
+++ libcaca-da28e9684ef445ac8d42745644336b8a75c01855/caca/dither.c
@@ -991,10 +991,10 @@ int caca_dither_bitmap(caca_canvas_t *cv
         /* First get RGB */
         if(d->antialias)
         {
-            fromx = (x - x1) * w / deltax;
-            fromy = (y - y1) * h / deltay;
-            tox = (x - x1 + 1) * w / deltax;
-            toy = (y - y1 + 1) * h / deltay;
+            fromx = (uint64_t)(x - x1) * w / deltax;
+            fromy = (uint64_t)(y - y1) * h / deltay;
+            tox = (uint64_t)(x - x1 + 1) * w / deltax;
+            toy = (uint64_t)(y - y1 + 1) * h / deltay;
 
             /* We want at least one pixel */
             if(tox == fromx) tox++;
@@ -1017,10 +1017,10 @@ int caca_dither_bitmap(caca_canvas_t *cv
         }
         else
         {
-            fromx = (x - x1) * w / deltax;
-            fromy = (y - y1) * h / deltay;
-            tox = (x - x1 + 1) * w / deltax;
-            toy = (y - y1 + 1) * h / deltay;
+            fromx = (uint64_t)(x - x1) * w / deltax;
+            fromy = (uint64_t)(y - y1) * h / deltay;
+            tox = (uint64_t)(x - x1 + 1) * w / deltax;
+            toy = (uint64_t)(y - y1 + 1) * h / deltay;
 
             /* tox and toy can overflow the canvas, but they cannot overflow
              * when averaged with fromx and fromy because these are guaranteed
openSUSE Build Service is sponsored by