[PATCH] Use long instead of int when retrieving DIVE_DATE via gtk_tree_model_get

Lubomir I. Ivanov neolit123 at gmail.com
Wed Sep 19 15:38:40 PDT 2012

From: "Lubomir I. Ivanov" <neolit123 at gmail.com>


When requesting gtk_tree_model_get() to write to a local variable
deep inside the gtk function implementation in question (GLib), there are
not much safety checks to warn if our passed variable to the vararg list
is of the correct type, which is unlike gtk_tree_model_get_value(),
which will report typed errors.

This solves a bug that may potentially result in undefined behaviour
on some x64 OS (e.g Ubuntu 12.04 x64).

Reported-by: Miika Turkia <miika.turkia at gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
 divelist.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/divelist.c b/divelist.c
index f032e62..5907486 100644
--- a/divelist.c
+++ b/divelist.c
@@ -378,15 +378,16 @@ static void date_data_func(GtkTreeViewColumn *col,
 			   GtkTreeIter *iter,
 			   gpointer data)
-	int val, idx, nr;
+	int idx, nr;
+	long date;
 	struct tm *tm;
 	time_t when;
 	char buffer[40];
-	gtk_tree_model_get(model, iter, DIVE_INDEX, &idx, DIVE_DATE, &val, -1);
+	gtk_tree_model_get(model, iter, DIVE_INDEX, &idx, DIVE_DATE, &date, -1);
 	nr = gtk_tree_model_iter_n_children(model, iter);
 	/* 2038 problem */
-	when = val;
+	when = date;
 	tm = gmtime(&when);
 	if (idx < 0) {

More information about the subsurface mailing list