String "-3" will be wrongly converted to -34 by strtosz_suffix().
strtosz_suffix_unit() only returns integer in success situation.

Signed-off-by: Amos Kong <ak...@redhat.com>
---
 qapi/opts-visitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 5d830a2..881e1b9 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -472,7 +472,7 @@ opts_type_size(Visitor *v, uint64_t *obj, const char *name, 
Error **errp)
 
     val = strtosz_suffix(opt->str ? opt->str : "", &endptr,
                          STRTOSZ_DEFSUFFIX_B);
-    if (val != -1 && *endptr == '\0') {
+    if (val >= 0 && *endptr == '\0') {
         *obj = val;
         processed(ov, name);
         return;
-- 
1.9.0


Reply via email to