[gtk: 1/2] textbtree: Initialize to zero the tags counting array
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 1/2] textbtree: Initialize to zero the tags counting array
- Date: Fri, 9 Jul 2021 10:56:52 +0000 (UTC)
commit 10bdf8c645a6ef22f273c0f9120ef4f1c51568e6
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Fri Jul 9 03:34:40 2021 +0200
textbtree: Initialize to zero the tags counting array
We're using the tag contents array to count the number of invisible tags
set but we always increase it without being initialized.
This may lead to unexpected behavior when traversing them and it's
causing a reliable failure in the textiter tests under s390x.
So, memset that area content to 0 once allocated. It's not needed to do
the same for the tags themselves as we always assign them.
Conditional jump or move depends on uninitialised value(s)
at 0x4CFAA00: _gtk_text_btree_char_is_invisible (gtktextbtree.c:2569)
by 0x4B8A1BB: find_visible_by_log_attrs (gtktextiter.c:3244)
by 0x10E93D: check_backward_visible_word_start (textiter.c:484)
by 0x10E93D: test_visible_word_boundaries (textiter.c:523)
by 0x533288F: g_test_run_suite (in /usr/lib/s390x-linux-gnu/libglib-2.0.so.0)
by 0x53328E7: g_test_run (in /usr/lib/s390x-linux-gnu/libglib-2.0.so.0)
by 0x109CC1: main (textiter.c:807)
gtk/gtktextbtree.c | 2 ++
1 file changed, 2 insertions(+)
---
diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c
index 0acc023a09..91ab3351a8 100644
--- a/gtk/gtktextbtree.c
+++ b/gtk/gtktextbtree.c
@@ -2483,6 +2483,8 @@ _gtk_text_btree_char_is_invisible (const GtkTextIter *iter)
tagCnts = g_alloca (sizeof (int) * numTags);
tags = g_alloca (sizeof (GtkTextTag *) * numTags);
+ memset (tagCnts, 0, sizeof (int) * numTags);
+
/*
* Record tag toggles within the line of indexPtr but preceding
* indexPtr.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]