MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / stbi__mul2sizes_valid

Function stbi__mul2sizes_valid

lite/example/cpp_example/mge/cv/stb_image.h:1039–1046  ·  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

1037// returns 1 if the product is valid, 0 on overflow.
1038// negative factors are considered invalid.
1039static int stbi__mul2sizes_valid(int a, int b) {
1040 if (a < 0 || b < 0)
1041 return 0;
1042 if (b == 0)
1043 return 1; // mul-by-0 is always safe
1044 // portable way to check for no overflows in a*b
1045 return a <= INT_MAX / b;
1046}
1047
1048#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || \
1049 !defined(STBI_NO_HDR)

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