json: avoid converting random string to floats

Only allow the json float characters when converting to float.
This avoids NAN, INF, 0xffe4 etc to be seen as a json float.
This commit is contained in:
Wim Taymans 2022-07-11 11:50:58 +02:00
parent bdfde2fdf0
commit cbbc4baa3f
2 changed files with 3 additions and 1 deletions

View file

@ -86,7 +86,7 @@ static void expect_float(struct spa_json *it, float val)
{
const char *value;
int len;
float f;
float f = 0.0f;
pwtest_int_gt((len = spa_json_next(it, &value)), 0);
check_type(TYPE_FLOAT, value, len);
pwtest_int_gt(spa_json_parse_float(value, len, &f), 0);