summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2017-02-15 09:56:49 +0000
committerPhilip Withnall <withnall@endlessm.com>2017-02-16 10:46:44 +0000
commitbfe9cdc64ebb1ce0da532c47147634bd15c29b7d (patch)
tree4bbc605d13709624cbaccb63e21aa86a5a794962
parent4cd190eb567173c6d10419f379f2facb1a59d7eb (diff)
downloadpango-bfe9cdc64ebb1ce0da532c47147634bd15c29b7d.tar.gz
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
-rw-r--r--pango/pango-layout.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 9452c9b8..791c3db7 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;
}