From: Simon McVittie Date: Fri, 3 Dec 2021 15:52:16 +0000 (+0000) Subject: _dbus_win_set_error_from_last_error: Always set the error X-Git-Tag: dbus-1.13.20~18^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d40cd238520f0e7a380b81be050a8f77357ade5;p=thirdparty%2Fdbus.git _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 --- diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index e9de93400..950d900a3 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); } /**