From: Simon McVittie Date: Wed, 2 Nov 2011 15:50:45 +0000 (+0000) Subject: _dbus_loop_new: don't crash on OOM allocating socket set X-Git-Tag: dbus-1.5.10~71^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f4ed9def33c359142c340f28345755ca37663f2;p=platform%2Fupstream%2Fdbus.git _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 --- 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; }