From 6520ecde58635992602b37a01060f9fa58d029a9 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Mon, 17 Jan 2011 11:53:57 +0000 Subject: [PATCH] dbus-nonce: check results of _dbus_string_init for OOM Origin: vendor, Maemo Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33128 Bug-NB: NB#180486 Reviewed-by: Simon McVittie --- dbus/dbus-nonce.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index a7a82f1..d7cee64 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -137,7 +137,8 @@ _dbus_accept_with_noncefile (int listen_fd, const DBusNonceFile *noncefile) DBusString nonce; _dbus_assert (noncefile != NULL); - _dbus_string_init (&nonce); + if (!_dbus_string_init (&nonce)) + return -1; //PENDING(kdab): set better errors if (_dbus_read_nonce (_dbus_noncefile_get_path(noncefile), &nonce, NULL) != TRUE) return -1; @@ -161,7 +162,11 @@ generate_and_write_nonce (const DBusString *filename, DBusError *error) _DBUS_ASSERT_ERROR_IS_CLEAR (error); - _dbus_string_init (&nonce); + if (!_dbus_string_init (&nonce)) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + return FALSE; + } if (!_dbus_generate_random_bytes (&nonce, 16)) { -- 2.7.4