MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / stbi__addints_valid

Function stbi__addints_valid

common/stb_image.h:1033–1039  ·  view source on GitHub ↗

returns 1 if the sum of two signed ints is valid (between -2^31 and 2^31-1 inclusive), 0 on overflow.

Source from the content-addressed store, hash-verified

1031
1032// returns 1 if the sum of two signed ints is valid (between -2^31 and 2^31-1 inclusive), 0 on overflow.
1033static int stbi__addints_valid(int a, int b) {
1034 if ((a >= 0) != (b >= 0))
1035 return 1; // a and b have different signs, so no overflow
1036 if (a < 0 && b < 0)
1037 return a >= INT_MIN - b; // same as a + b >= INT_MIN; INT_MIN - b cannot overflow since b < 0.
1038 return a <= INT_MAX - b;
1039}
1040
1041// returns 1 if the product of two signed shorts is valid, 0 on overflow.
1042static int stbi__mul2shorts_valid(short a, short b) {

Callers 2

stbi__jpeg_decode_blockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected