[pango] pango-layout: Add a clarifying assertion



commit bfe9cdc64ebb1ce0da532c47147634bd15c29b7d
Author: Philip Withnall <withnall endlessm com>
Date:   Wed Feb 15 09:56:49 2017 +0000

    pango-layout: Add a clarifying assertion
    
    In pango_layout_index_to_pos(), it looks like layout_line could be
    dereferenced while still NULL in the first loop iteration. This is not
    the case, as other bits of PangoLayout ensure its start_index is always
    0, so this branch is never taken. Add an assertion to clarify that and
    guide static analysis.
    
    Coverity ID: 1391700
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=778656

 pango/pango-layout.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 9452c9b..791c3db 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -2144,7 +2144,11 @@ pango_layout_index_to_pos (PangoLayout    *layout,
            {
              /* index is in the paragraph delimiters, move to
               * end of previous line
+              *
+              * This shouldn’t occur in the first loop iteration as the first
+              * line’s start_index should always be 0.
               */
+             g_assert (layout_line != NULL);
              index = layout_line->start_index + layout_line->length;
              break;
            }


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