Commit b5bf3389 authored by Simon McVittie's avatar Simon McVittie
Browse files

_dbus_string_append_printf_valist: avoid leaking copy of varargs

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=88087

Signed-off-by: default avatarSimon McVittie <simon.mcvittie@collabora.co.uk>
parent 04056bba
...@@ -1073,6 +1073,7 @@ _dbus_string_append_printf_valist (DBusString *str, ...@@ -1073,6 +1073,7 @@ _dbus_string_append_printf_valist (DBusString *str,
const char *format, const char *format,
va_list args) va_list args)
{ {
dbus_bool_t ret = FALSE;
int len; int len;
va_list args_copy; va_list args_copy;
...@@ -1084,21 +1085,21 @@ _dbus_string_append_printf_valist (DBusString *str, ...@@ -1084,21 +1085,21 @@ _dbus_string_append_printf_valist (DBusString *str,
len = _dbus_printf_string_upper_bound (format, args); len = _dbus_printf_string_upper_bound (format, args);
if (len < 0) if (len < 0)
return FALSE; goto out;
if (!_dbus_string_lengthen (str, len)) if (!_dbus_string_lengthen (str, len))
{ {
/* don't leak the copy */ goto out;
va_end (args_copy);
return FALSE;
} }
vsprintf ((char*) (real->str + (real->len - len)), vsprintf ((char*) (real->str + (real->len - len)),
format, args_copy); format, args_copy);
ret = TRUE;
out:
va_end (args_copy); va_end (args_copy);
return TRUE; return ret;
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment