From f1e7b4f56d2d93bb2ed11b007c95aa81c30f748a Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 11 Oct 2013 16:35:17 +0800 Subject: [PATCH v4 1/3] Correctly set number of arguments already handled At privous, which increments the number of arguments already handled in the last of loop, however, if there is any invalid argument, then it will "goto out" and the number of arguments already handled is now incorrect. A following patch will use the number of arguments already handled as a loop terminate condition, so it's good to fix it before. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=21259 --- dbus/dbus-message.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 9546da1..4f234d5 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -982,15 +982,16 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, } #endif + /* how many arguments already handled */ + i++; + spec_type = va_arg (var_args, int); if (!_dbus_type_reader_next (&real->u.reader) && spec_type != DBUS_TYPE_INVALID) { dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, - "Message has only %d arguments, but more were expected", i + 1); + "Message has only %d arguments, but more were expected", i); goto out; } - - i++; } retval = TRUE; -- 1.7.9.5