mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-06 15:08:01 +02:00
dbus_message_iter_append_basic: Don't leak signature if appending fd fails
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=101568
(cherry picked from commit 8384e79551)
This commit is contained in:
parent
4157b6a191
commit
0907c2b9fd
1 changed files with 9 additions and 3 deletions
|
|
@ -2785,20 +2785,22 @@ dbus_message_iter_append_basic (DBusMessageIter *iter,
|
|||
int *fds;
|
||||
dbus_uint32_t u;
|
||||
|
||||
ret = FALSE;
|
||||
|
||||
/* First step, include the fd in the fd list of this message */
|
||||
if (!(fds = expand_fd_array(real->message, 1)))
|
||||
return FALSE;
|
||||
goto out;
|
||||
|
||||
*fds = _dbus_dup(*(int*) value, NULL);
|
||||
if (*fds < 0)
|
||||
return FALSE;
|
||||
goto out;
|
||||
|
||||
u = real->message->n_unix_fds;
|
||||
|
||||
/* Second step, write the index to the fd */
|
||||
if (!(ret = _dbus_type_writer_write_basic (&real->u.writer, DBUS_TYPE_UNIX_FD, &u))) {
|
||||
_dbus_close(*fds, NULL);
|
||||
return FALSE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
real->message->n_unix_fds += 1;
|
||||
|
|
@ -2817,6 +2819,9 @@ dbus_message_iter_append_basic (DBusMessageIter *iter,
|
|||
freed. */
|
||||
#else
|
||||
ret = FALSE;
|
||||
/* This is redundant (we could just fall through), but it avoids
|
||||
* -Wunused-label in builds that don't HAVE_UNIX_FD_PASSING */
|
||||
goto out;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
|
@ -2824,6 +2829,7 @@ dbus_message_iter_append_basic (DBusMessageIter *iter,
|
|||
ret = _dbus_type_writer_write_basic (&real->u.writer, type, value);
|
||||
}
|
||||
|
||||
out:
|
||||
if (!_dbus_message_iter_close_signature (real))
|
||||
ret = FALSE;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue