From 7dc9a94195df6e8a2fd91c3fcf378dd0ae983cad Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 6 Jan 2015 22:12:16 +0000 Subject: [PATCH] _dbus_string_append_printf_valist: avoid leaking copy of varargs Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88087 --- dbus/dbus-string.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 15cff9c..98d9f2b 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -1073,6 +1073,7 @@ _dbus_string_append_printf_valist (DBusString *str, const char *format, va_list args) { + dbus_bool_t ret = FALSE; int len; va_list args_copy; @@ -1084,21 +1085,21 @@ _dbus_string_append_printf_valist (DBusString *str, len = _dbus_printf_string_upper_bound (format, args); if (len < 0) - return FALSE; + goto out; if (!_dbus_string_lengthen (str, len)) { - /* don't leak the copy */ - va_end (args_copy); - return FALSE; + goto out; } vsprintf ((char*) (real->str + (real->len - len)), format, args_copy); + ret = TRUE; +out: va_end (args_copy); - return TRUE; + return ret; } /** -- 2.1.4