]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
_dbus_win_set_error_from_last_error: Always set the error
authorSimon McVittie <smcv@collabora.com>
Fri, 3 Dec 2021 15:52:16 +0000 (15:52 +0000)
committerSimon McVittie <smcv@collabora.com>
Fri, 3 Dec 2021 15:55:59 +0000 (15:55 +0000)
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>
dbus/dbus-sysdeps-win.c

index e9de9340092d5c22590990bf0c3cce68e9e056c9..950d900a3384ed2de02fdb49f2a4da14d72f17ef 100644 (file)
@@ -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);
 }
 
 /**