From 09efe97bfd22b86697ad46e7ce3ed75a17d5b764 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 3 Mar 2018 17:30:39 -0500 Subject: [PATCH] qapi: Fix string input visitor regression for empty lists Visiting a list when input is the empty string should result in an empty list, not an error. Noticed when commit 3d089ce belatedly added tests, but simply accepted as weird then. It's actually a regression: broken in commit 74f24cb, v2.7.0. Fix it, and throw in another test case for empty string. Backports commit d2788227c6185c72d88ef3127e9fed41686f8e39 from qemu --- qemu/qapi/string-input-visitor.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu/qapi/string-input-visitor.c b/qemu/qapi/string-input-visitor.c index 8180be3f..9661f91f 100644 --- a/qemu/qapi/string-input-visitor.c +++ b/qemu/qapi/string-input-visitor.c @@ -54,6 +54,10 @@ static int parse_str(StringInputVisitor *siv, const char *name, Error **errp) return 0; } + if (!*str) { + return 0; + } + do { errno = 0; start = strtoll(str, &endptr, 0);