[pango/fix-emoji-in-tests] Avoid an out-of-bound access



commit 8f7c1ed695652df879417e748f09425e644a1d4d
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Nov 27 09:40:35 2021 -0500

    Avoid an out-of-bound access
    
    We can only use the width of the previous char
    if we are not at the first char. Found by asan.

 pango/pango-layout.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 703f4573..40e24cbb 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -3750,7 +3750,7 @@ find_break_extra_width (PangoLayout    *layout,
     {
       ensure_hyphen_width (state);
 
-      if (layout->log_attrs[state->start_offset + pos].break_removes_preceding)
+      if (layout->log_attrs[state->start_offset + pos].break_removes_preceding && pos > 0)
         return state->hyphen_width - state->log_widths[state->log_widths_offset + pos - 1];
       else
         return state->hyphen_width;


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