summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2001-05-16 18:16:57 +0000
committerJonathan Blandford <jrb@src.gnome.org>2001-05-16 18:16:57 +0000
commit97fb7b787866125933df5a832f9869a1bde4bd17 (patch)
treee6ea058c6dcc273bdb9fa2db78ca2f35c9a4bd65 /gtk
parent2970a2feeece3e2c93760099394f2587379ddb09 (diff)
downloadgtk+-97fb7b787866125933df5a832f9869a1bde4bd17.tar.gz
fix bug #54699 where paths weren't being checked for correctness.
Wed May 16 14:06:01 2001 Jonathan Blandford <jrb@redhat.com> * gtk/gtktreemodel.c (gtk_tree_path_new_from_string): fix bug #54699 where paths weren't being checked for correctness.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtktreemodel.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/gtk/gtktreemodel.c b/gtk/gtktreemodel.c
index c79e1fe90d..db062631ac 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;