From 3f4ed9def33c359142c340f28345755ca37663f2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 2 Nov 2011 15:50:45 +0000 Subject: [PATCH] _dbus_loop_new: don't crash on OOM allocating socket set Also don't leak the socket set if allocating watches failed, or vice versa. Based on review feedback from wjt. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33337 --- dbus/dbus-mainloop.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c index 383ac2c..e63019f 100644 --- a/dbus/dbus-mainloop.c +++ b/dbus/dbus-mainloop.c @@ -157,8 +157,14 @@ _dbus_loop_new (void) loop->socket_set = _dbus_socket_set_new (0); - if (loop->watches == NULL) + if (loop->watches == NULL || loop->socket_set == NULL) { + if (loop->watches != NULL) + _dbus_hash_table_unref (loop->watches); + + if (loop->socket_set != NULL) + _dbus_socket_set_free (loop->socket_set); + dbus_free (loop); return NULL; } -- 2.7.4