MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / stbi__mul2sizes_valid

Function stbi__mul2sizes_valid

include/stb/stb_image.h:1014–1020  ·  view source on GitHub ↗

returns 1 if the product is valid, 0 on overflow. negative factors are considered invalid.

Source from the content-addressed store, hash-verified

1012// returns 1 if the product is valid, 0 on overflow.
1013// negative factors are considered invalid.
1014static int stbi__mul2sizes_valid(int a, int b)
1015{
1016 if (a < 0 || b < 0) return 0;
1017 if (b == 0) return 1; // mul-by-0 is always safe
1018 // portable way to check for no overflows in a*b
1019 return a <= INT_MAX/b;
1020}
1021
1022#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR)
1023// returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow

Callers 3

stbi__mad2sizes_validFunction · 0.85
stbi__mad3sizes_validFunction · 0.85
stbi__mad4sizes_validFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected