aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qapi/qobject-input-visitor.c3
-rw-r--r--tests/test-qobject-input-visitor.c6
2 files changed, 8 insertions, 1 deletions
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index d0f0002317..eac40f618a 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -13,6 +13,7 @@
*/
#include "qemu/osdep.h"
+#include <math.h>
#include "qapi/error.h"
#include "qapi/qobject-input-visitor.h"
#include "qapi/visitor-impl.h"
@@ -568,7 +569,7 @@ static void qobject_input_type_number_keyval(Visitor *v, const char *name,
errno = 0;
*obj = strtod(str, &endp);
- if (errno || endp == str || *endp) {
+ if (errno || endp == str || *endp || !isfinite(*obj)) {
/* TODO report -ERANGE more nicely */
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
full_name(qiv, name), "number");
diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-visitor.c
index f965743b6e..e2aabbe972 100644
--- a/tests/test-qobject-input-visitor.c
+++ b/tests/test-qobject-input-visitor.c
@@ -278,11 +278,17 @@ static void test_visitor_in_number_str_keyval(TestInputVisitorData *data,
{
double res = 0, value = 3.14;
Visitor *v;
+ Error *err = NULL;
v = visitor_input_test_init_full(data, true, "\"3.14\"");
visit_type_number(v, NULL, &res, &error_abort);
g_assert_cmpfloat(res, ==, value);
+
+ v = visitor_input_test_init_full(data, true, "\"inf\"");
+
+ visit_type_number(v, NULL, &res, &err);
+ error_free_or_abort(&err);
}
static void test_visitor_in_number_str_fail(TestInputVisitorData *data,