c99-snprintf
c99-snprintf copied to clipboard
Static analysis: Overflowed return value
Coverity Scan reports an Overflowed return value from function myround
.
static UINTMAX_T
myround(LDOUBLE value)
{
UINTMAX_T intpart = cast(value);
//1. Condition (value -= intpart) < 0.5, taking false branch.
//2. overflow: Add operation overflows on operands intpart and 1UL.
//CID 59973 (#1 of 1): Overflowed return value (INTEGER_OVERFLOW)
//3. overflow_sink: Overflowed or truncated value (or a value computed from an overflowed or truncated value) ((value -= intpart) < 0.5) ? intpart : (intpart + 1UL) used as return value.
return ((value -= intpart) < 0.5) ? intpart : intpart + 1;
}
The call to cast()
can return UINTMAX_MAX
, in which case the return statement will overflow.