Coverity doesn't like this, complaining that assignment to an object
with overlapping storage without exact overlap and compatible types can
cause undefined behaviour.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
}
if (would_overflow(top->u.integer, b))
- { -- num_digits;
+ { double dbl = (double)top->u.integer;
+ -- num_digits;
-- state.ptr;
top->type = json_double;
- top->u.dbl = (double)top->u.integer;
+ top->u.dbl = dbl;
continue;
}
}
else if (b == '.' && top->type == json_integer)
{
+ double dbl = (double)top->u.integer;
if (!num_digits)
{ sprintf (error, "%d:%d: Expected digit before `.`", line_and_col);
goto e_failed;
}
top->type = json_double;
- top->u.dbl = (double) top->u.integer;
+ top->u.dbl = dbl;
flags |= flag_num_got_decimal;
num_digits = 0;
if (top->type == json_integer)
{
+ double dbl = (double) top->u.integer;
top->type = json_double;
- top->u.dbl = (double) top->u.integer;
+ top->u.dbl = dbl;
}
num_digits = 0;