summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2017-11-21 14:43:01 +0000
committerSimon McVittie <smcv@collabora.com>2017-11-24 12:17:32 +0000
commit9ded6907e66b89c3c74620a4485e8f752f092a60 (patch)
tree6baa425bf5ffcd8eab4cc04da7c4e5c8310cda93
parentd48d31cc21f8b4b9f976304d5cd8672c0e34720d (diff)
_dbus_listen_tcp_socket: Don't rely on dbus_realloc setting errno
dbus_realloc() doesn't guarantee to set errno (if it did, the only reasonable thing it could set it to would be ENOMEM). In particular, faking OOM conditions doesn't set it. This can cause an assertion failure when OOM tests assert that the only error that can validly occur is DBUS_ERROR_NO_MEMORY. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104
-rw-r--r--dbus/dbus-sysdeps-unix.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index f103323c5..9f859845d 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -1581,11 +1581,9 @@ _dbus_listen_tcp_socket (const char *host,
newlisten_fd = dbus_realloc(listen_fd, sizeof(DBusSocket)*(nlisten_fd+1));
if (!newlisten_fd)
{
- saved_errno = errno;
_dbus_close (fd, NULL);
- dbus_set_error (error, _dbus_error_from_errno (saved_errno),
- "Failed to allocate file handle array: %s",
- _dbus_strerror (saved_errno));
+ dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
+ "Failed to allocate file handle array");
goto failed;
}
listen_fd = newlisten_fd;