On 04/13/2016 03:04 PM, Marcel Böhme wrote:
Hi Bernd,
Shouldn't we check for overflows before performing the +1 addition
(i.e. 0 <= num < INT_MAX)? Ideally we'd also have a way to signal
from d_number if we had an overflow while parsing that number.
Without an overflow signal, d_number will already be prone to return
a negative number for supposedly non-negative numbers (those not
preceded with ’n’). In that case an overflow check would be
unnecessary in d_compact_number which is supposed to always return a
positive number or a negative one (-1). If you decide in favour of an
overflow signal, it must be handled by the call-sites. Not sure what
the “default behaviour” should be then. Otherwise, we can simply
assume that the call sites for d_number can handle negative numbers.

Shouldn't we look into fixing d_number eventually so it can signal error?

index = d_compact_number (di) + 1; if (index == 0) return NULL;

which probably ought to have the same kind of check (I'll note that
at this point we've accumulated two "+1"s, I'll assume that's what
we want).
Yes. There should be an overflow check here.

Could you update the patch for that?


Bernd

Reply via email to