diff options
author | Simon McVittie <smcv@collabora.com> | 2021-12-03 15:52:16 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2021-12-03 15:55:59 +0000 |
commit | 0d40cd238520f0e7a380b81be050a8f77357ade5 (patch) | |
tree | 652c61e0acd79aad5f528c361db01741421e60ab | |
parent | e8b34b419e44e0b95622f45c0f17487e241b1961 (diff) | |
download | dbus-0d40cd238520f0e7a380b81be050a8f77357ade5.tar.gz |
_dbus_win_set_error_from_last_error: Always set the error
If we run out of memory while setting an error, we need to recover by
setting the error to "out of memory" instead of the original error.
Otherwise, the error indicator would be unset, breaking the rules of
our error model.
Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r-- | dbus/dbus-sysdeps-win.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index e9de9340..950d900a 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -4031,13 +4031,17 @@ _dbus_win_set_error_from_last_error (DBusError *error, dbus_bool_t retval; if (!_dbus_string_init (&str)) - goto out; + { + _DBUS_SET_OOM (error); + goto out; + } va_start (args, format); retval = _dbus_string_append_printf_valist (&str, format, args); va_end (args); if (!retval) { + _DBUS_SET_OOM (error); _dbus_string_free (&str); goto out; } @@ -4053,6 +4057,8 @@ _dbus_win_set_error_from_last_error (DBusError *error, out: if (message != NULL) _dbus_win_free_error_string (message); + + _DBUS_ASSERT_ERROR_IS_SET (error); } /** |