diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2014-06-20 21:25:07 +0100 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2016-04-02 12:27:05 +0100 |
commit | d09c219696512d5f365e0920c106b58c0d70bd19 (patch) | |
tree | 8ff505d82412dcbf50d8ce62e736d0d806d63ab6 | |
parent | 28dcafa09b4168cc586cb493f46c2df58442f1f1 (diff) | |
download | glib-d09c219696512d5f365e0920c106b58c0d70bd19.tar.gz |
glocalfile: Assert against a potential NULL pointer dereference
This was confusing some static analysis. Through canonicalize_filename()
at construction time, we guaranteed that ->filename is canonical and
absolute, so g_path_skip_root() should never fail.
https://bugzilla.gnome.org/show_bug.cgi?id=731988
-rw-r--r-- | gio/glocalfile.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gio/glocalfile.c b/gio/glocalfile.c index a5a6beb45..0a1cadfcf 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -503,8 +503,11 @@ g_local_file_get_parent (GFile *file) char *dirname; GFile *parent; - /* Check for root */ + /* Check for root; local->filename is guaranteed to be absolute, so + * g_path_skip_root() should never return NULL. */ non_root = g_path_skip_root (local->filename); + g_assert (non_root != NULL); + if (*non_root == 0) return NULL; |