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 <simon.mcvittie@collabora.co.uk>
This commit is contained in:
Christian Dywan 2011-01-17 11:53:57 +00:00 committed by Simon McVittie
parent 84d4ed242a
commit 6520ecde58

View 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))
{