MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / CanAdd

Function CanAdd

include/bmpread/bmpread.c:66–69  ·  view source on GitHub ↗

I've tried to make every effort to remove the possibility of undefined * behavior and prevent related errors where maliciously crafted files could * lead to buffer overflows or the like. To that end, we'll start with some * functions that check various operations for behaving as expected. This one * returns nonzero if the two size_ts can be added without wrapping, or 0 if * the result would

Source from the content-addressed store, hash-verified

64 * the result would wrap.
65 */
66static int CanAdd(size_t a, size_t b)
67{
68 return a <= SIZE_MAX - b;
69}
70
71/* Returns nonzero if the two size_ts can be multiplied without wrapping, or 0
72 * if the result would wrap. b must not be 0 (we don't even check here since

Callers 1

GetLineLengthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected