From 97fb7b787866125933df5a832f9869a1bde4bd17 Mon Sep 17 00:00:00 2001 From: Jonathan Blandford Date: Wed, 16 May 2001 18:16:57 +0000 Subject: fix bug #54699 where paths weren't being checked for correctness. Wed May 16 14:06:01 2001 Jonathan Blandford * gtk/gtktreemodel.c (gtk_tree_path_new_from_string): fix bug #54699 where paths weren't being checked for correctness. --- ChangeLog | 5 +++++ ChangeLog.pre-2-0 | 5 +++++ ChangeLog.pre-2-10 | 5 +++++ ChangeLog.pre-2-2 | 5 +++++ ChangeLog.pre-2-4 | 5 +++++ ChangeLog.pre-2-6 | 5 +++++ ChangeLog.pre-2-8 | 5 +++++ gtk/gtktreemodel.c | 31 +++++++++++++++++++++++-------- 8 files changed, 58 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index f85c19820..d97f0f09f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed May 16 14:06:01 2001 Jonathan Blandford + + * gtk/gtktreemodel.c (gtk_tree_path_new_from_string): fix bug + #54699 where paths weren't being checked for correctness. + Tue May 15 20:13:24 2001 Jonathan Blandford * gtk/gtktreeviewcolumn.c: You can now set all sorts of properties diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index f85c19820..d97f0f09f 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,8 @@ +Wed May 16 14:06:01 2001 Jonathan Blandford + + * gtk/gtktreemodel.c (gtk_tree_path_new_from_string): fix bug + #54699 where paths weren't being checked for correctness. + Tue May 15 20:13:24 2001 Jonathan Blandford * gtk/gtktreeviewcolumn.c: You can now set all sorts of properties diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f85c19820..d97f0f09f 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,8 @@ +Wed May 16 14:06:01 2001 Jonathan Blandford + + * gtk/gtktreemodel.c (gtk_tree_path_new_from_string): fix bug + #54699 where paths weren't being checked for correctness. + Tue May 15 20:13:24 2001 Jonathan Blandford * gtk/gtktreeviewcolumn.c: You can now set all sorts of properties diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index f85c19820..d97f0f09f 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,8 @@ +Wed May 16 14:06:01 2001 Jonathan Blandford + + * gtk/gtktreemodel.c (gtk_tree_path_new_from_string): fix bug + #54699 where paths weren't being checked for correctness. + Tue May 15 20:13:24 2001 Jonathan Blandford * gtk/gtktreeviewcolumn.c: You can now set all sorts of properties diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index f85c19820..d97f0f09f 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,8 @@ +Wed May 16 14:06:01 2001 Jonathan Blandford + + * gtk/gtktreemodel.c (gtk_tree_path_new_from_string): fix bug + #54699 where paths weren't being checked for correctness. + Tue May 15 20:13:24 2001 Jonathan Blandford * gtk/gtktreeviewcolumn.c: You can now set all sorts of properties diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index f85c19820..d97f0f09f 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,8 @@ +Wed May 16 14:06:01 2001 Jonathan Blandford + + * gtk/gtktreemodel.c (gtk_tree_path_new_from_string): fix bug + #54699 where paths weren't being checked for correctness. + Tue May 15 20:13:24 2001 Jonathan Blandford * gtk/gtktreeviewcolumn.c: You can now set all sorts of properties diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f85c19820..d97f0f09f 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,8 @@ +Wed May 16 14:06:01 2001 Jonathan Blandford + + * gtk/gtktreemodel.c (gtk_tree_path_new_from_string): fix bug + #54699 where paths weren't being checked for correctness. + Tue May 15 20:13:24 2001 Jonathan Blandford * gtk/gtktreeviewcolumn.c: You can now set all sorts of properties diff --git a/gtk/gtktreemodel.c b/gtk/gtktreemodel.c index c79e1fe90..db062631a 100644 --- a/gtk/gtktreemodel.c +++ b/gtk/gtktreemodel.c @@ -145,22 +145,24 @@ gtk_tree_path_new (void) * gtk_tree_path_new_from_string: * @path: The string representation of a path. * - * Creates a new #GtkTreePath initialized to @path. @path is expected - * to be a colon separated list of numbers. For example, the string - * "10:4:0" would create a path of depth 3 pointing to the 11th child - * of the root node, the 5th child of that 11th child, and the 1st - * child of that 5th child. + * Creates a new #GtkTreePath initialized to @path. @path is expected to be a + * colon separated list of numbers. For example, the string "10:4:0" would + * create a path of depth 3 pointing to the 11th child of the root node, the 5th + * child of that 11th child, and the 1st child of that 5th child. If an invalid + * path is past in, NULL is returned. * - * Return value: A newly created #GtkTreePath. + * Return value: A newly created #GtkTreePath, or NULL **/ GtkTreePath * gtk_tree_path_new_from_string (gchar *path) { GtkTreePath *retval; + gchar *orig_path = path; gchar *ptr; gint i; - g_return_val_if_fail (path != NULL, gtk_tree_path_new ()); + g_return_val_if_fail (path != NULL, NULL); + g_return_val_if_fail (*path != '\000', NULL); retval = gtk_tree_path_new (); @@ -169,9 +171,20 @@ gtk_tree_path_new_from_string (gchar *path) i = strtol (path, &ptr, 10); gtk_tree_path_append_index (retval, i); + if (i < 0) + { + g_warning (G_STRLOC"Negative numbers in path %s passed to gtk_tree_path_new_from_string", orig_path); + gtk_tree_path_free (retval); + return NULL; + } if (*ptr == '\000') break; - /* FIXME: should we error out if this is not a ':', or should we be tolerant? */ + if (ptr == path || *ptr != ':') + { + g_warning (G_STRLOC"Invalid path %s passed to gtk_tree_path_new_from_string", orig_path); + gtk_tree_path_free (retval); + return NULL; + } path = ptr + 1; } @@ -193,6 +206,8 @@ gtk_tree_path_to_string (GtkTreePath *path) gchar *retval, *ptr; gint i; + g_return_val_if_fail (path != NULL, NULL); + if (path->depth == 0) return NULL; -- cgit v1.2.1