returns 1 if the product is valid, 0 on overflow. negative factors are considered invalid.
| 1012 | // returns 1 if the product is valid, 0 on overflow. |
| 1013 | // negative factors are considered invalid. |
| 1014 | static 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 |
no outgoing calls
no test coverage detected