mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-07 03:58:00 +02:00
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
(cherry picked from commit 6d08f5c04e)
This commit is contained in:
parent
208af9a447
commit
d000891624
1 changed files with 6 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue