freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master 134db7b: [ftsdf] Fix segmentation fault.


From: Werner Lemberg
Subject: [freetype2-demos] master 134db7b: [ftsdf] Fix segmentation fault.
Date: Thu, 24 Mar 2022 02:06:06 -0400 (EDT)

branch: master
commit 134db7bb97afba63293fb5d3e57004e54f1bb49c
Author: Anuj Verma <anuj@womp.xyz>
Commit: Anuj Verma <anuj@womp.xyz>

    [ftsdf] Fix segmentation fault.
    
    * src/ftsdf.c (draw): Use integer to avoid overflow while reverse
    looping `j`.
---
 src/ftsdf.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/ftsdf.c b/src/ftsdf.c
index ef69bab..914d528 100644
--- a/src/ftsdf.c
+++ b/src/ftsdf.c
@@ -523,24 +523,24 @@
 
     /* Finally loop over all pixels inside the draw region        */
     /* and copy pixels from the sample region to the draw region. */
-    for ( FT_UInt  j = (FT_UInt)( draw_region.yMax - 1 ),
-                   y = (FT_UInt)sample_region.yMin;
+    for ( FT_Int  j = (FT_UInt)( draw_region.yMax - 1 ),
+                  y = (FT_UInt)sample_region.yMin;
           j >= draw_region.yMin;
           j--, y++ )
     {
-      for ( FT_UInt  i = (FT_UInt)draw_region.xMin,
-                     x = (FT_UInt)sample_region.xMin;
+      for ( FT_Int  i = (FT_UInt)draw_region.xMin,
+                    x = (FT_UInt)sample_region.xMin;
             i < draw_region.xMax;
             i++, x++ )
       {
-        FT_UInt  display_index = j * (FT_UInt)display->bitmap->width + i;
-        float    min_dist;
+        FT_Int  display_index = j * (FT_UInt)display->bitmap->width + i;
+        float   min_dist;
 
 
         if ( status.nearest_filtering )
         {
-          FT_UInt  bitmap_index = ( y / status.scale ) * bitmap->width +
-                                  x / status.scale;
+          FT_Int  bitmap_index = ( y / status.scale ) * bitmap->width +
+                                 x / status.scale;
           FT_Byte  pixel_value = buffer[bitmap_index];
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]