From 090d45175dee39891b49e2243b1426c041978894 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 21 Nov 2017 14:43:01 +0000 Subject: [PATCH 08/12] _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 --- dbus/dbus-sysdeps-unix.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index f103323c..9f859845 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; -- 2.15.0