notcurses icon indicating copy to clipboard operation
notcurses copied to clipboard

use better overflow check

Open mulle-nat opened this issue 4 months ago • 3 comments

This is a better mergable #2767, but my fork got out of sync and there were superflous commits in there. Sorry for the inconvenience. Here's my original comment.

I think you will like this much better. The other code was more or less a mitigation but this should be a better overflow checker. The multiplication does the zero check and the comparison checks that the multiplication doesn't overflow. calloc will then do the other overflow check.

Adding to this: The old code caught overflow with large negative numbers, but this one will catch any kind of overflow. Also the code is easier to understand IMO.

mulle-nat avatar Mar 02 '24 18:03 mulle-nat