From 0d40cd238520f0e7a380b81be050a8f77357ade5 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 3 Dec 2021 15:52:16 +0000 Subject: _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 --- dbus/dbus-sysdeps-win.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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); } /** -- cgit v1.2.1