From b048df8fea3cdf1462d80d401cc95791cc1b2d06 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 2 Feb 2015 18:15:02 +0000 Subject: [PATCH 10/12] _dbus_set_error_valist: add Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88810 --- dbus/dbus-errors.c | 26 ++++++++++++++++++++------ dbus/dbus-internals.h | 4 ++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/dbus/dbus-errors.c b/dbus/dbus-errors.c index 5d8f194..5a305ca 100644 --- a/dbus/dbus-errors.c +++ b/dbus/dbus-errors.c @@ -356,8 +356,6 @@ dbus_set_error (DBusError *error, const char *format, ...) { - DBusRealError *real; - DBusString str; va_list args; if (error == NULL) @@ -366,7 +364,26 @@ dbus_set_error (DBusError *error, /* it's a bug to pile up errors */ _dbus_return_if_error_is_set (error); _dbus_return_if_fail (name != NULL); - + + va_start (args, format); + _dbus_set_error_valist (error, name, format, args); + va_end (args); +} + +void +_dbus_set_error_valist (DBusError *error, + const char *name, + const char *format, + va_list args) +{ + DBusRealError *real; + DBusString str; + + _dbus_assert (name != NULL); + + if (error == NULL) + return; + _dbus_assert (error->name == NULL); _dbus_assert (error->message == NULL); @@ -384,14 +401,11 @@ dbus_set_error (DBusError *error, } else { - va_start (args, format); if (!_dbus_string_append_printf_valist (&str, format, args)) { _dbus_string_free (&str); - va_end (args); goto nomem; } - va_end (args); } real = (DBusRealError *)error; diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 4658b67..6b487f5 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -263,6 +263,10 @@ void _dbus_verbose_bytes_of_string (const DBusString *str, extern const char *_dbus_no_memory_message; #define _DBUS_SET_OOM(error) dbus_set_error_const ((error), DBUS_ERROR_NO_MEMORY, _dbus_no_memory_message) +void _dbus_set_error_valist (DBusError *error, + const char *name, + const char *format, + va_list args) _DBUS_GNUC_PRINTF (3, 0); #ifdef DBUS_ENABLE_EMBEDDED_TESTS /* Memory debugging */ -- 2.1.4