diff options
author | Simon McVittie <smcv@collabora.com> | 2017-11-06 19:10:42 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2017-11-07 11:38:43 +0000 |
commit | 6d08f5c04e601f16ef4ee2126a90c924b7e26df0 (patch) | |
tree | 432b2dad47227999710b82c56136da860b9d8b3a /dbus/dbus-nonce.c | |
parent | 0ea0e4b0fddd1109835b8b9f7a8319d59c8d9303 (diff) | |
download | dbus-6d08f5c04e601f16ef4ee2126a90c924b7e26df0.tar.gz |
do_noncefile_create: Avoid freeing uninitialized memory on error
We could free all of these without having ever successfully
initialized them.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103597
Diffstat (limited to 'dbus/dbus-nonce.c')
-rw-r--r-- | dbus/dbus-nonce.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index 49f87369..7f3118cd 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -280,6 +280,12 @@ do_noncefile_create (DBusNonceFile *noncefile, _dbus_assert (noncefile); + /* Make it valid to "free" these even if _dbus_string_init() runs + * out of memory: see comment in do_check_nonce() */ + _dbus_string_init_const (&randomStr, ""); + _dbus_string_init_const (&noncefile->dir, ""); + _dbus_string_init_const (&noncefile->path, ""); + if (!_dbus_string_init (&randomStr)) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); |