]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
nonce: Don't try to rmdir(NULL) on OOM
authorSimon McVittie <smcv@collabora.com>
Thu, 12 Jul 2018 12:32:10 +0000 (13:32 +0100)
committerSimon McVittie <smcv@collabora.com>
Thu, 2 Aug 2018 16:15:29 +0000 (17:15 +0100)
If re-initializing the string fails, it will be left in a state
where it has a length of 0 and a NULL buffer. That's valid to
"free", but not valid to pass to rmdir().

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=107194

dbus/dbus-nonce.c

index b56116b320020eec9ca1001d2a7ffd06695b9a79..ef5eb617f38dc26ff8a92c2ea5cd2347e467b4e9 100644 (file)
@@ -383,7 +383,7 @@ do_noncefile_create (DBusNonceFile **noncefile_out,
 
     return TRUE;
   on_error:
-    if (use_subdir)
+    if (use_subdir && _dbus_string_get_length (&noncefile->dir) != 0)
       _dbus_delete_directory (&noncefile->dir, NULL);
     _dbus_string_free (&noncefile->dir);
     _dbus_string_free (&noncefile->path);