]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Correctly set number of arguments already handled
authorChengwei Yang <chengwei.yang@intel.com>
Fri, 11 Oct 2013 08:35:17 +0000 (16:35 +0800)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 1 Nov 2013 11:24:18 +0000 (11:24 +0000)
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
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
dbus/dbus-message.c

index 9546da12546ec3ca258f6a3d635ea67da1270ec5..4f234d529a19ab6a5e3f4fd4345f14b7d0fdf2da 100644 (file)
@@ -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;