dbus-nonce: check results of _dbus_string_init for OOM
authorChristian Dywan <christian.dywan@lanedo.com>
Mon, 17 Jan 2011 11:53:57 +0000 (11:53 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 17 Jan 2011 11:54:08 +0000 (11:54 +0000)
Origin: vendor, Maemo
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33128
Bug-NB: NB#180486
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
dbus/dbus-nonce.c

index a7a82f1..d7cee64 100644 (file)
@@ -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))
     {