returns 1 if the product of two ints fits in a signed short, 0 on overflow.
| 1075 | |
| 1076 | // returns 1 if the product of two ints fits in a signed short, 0 on overflow. |
| 1077 | static int stbi__mul2shorts_valid(int a, int b) |
| 1078 | { |
| 1079 | if (b == 0 || b == -1) return 1; // multiplication by 0 is always 0; check for -1 so SHRT_MIN/b doesn't overflow |
| 1080 | if ((a >= 0) == (b >= 0)) return a <= SHRT_MAX/b; // product is positive, so similar to mul2sizes_valid |
| 1081 | if (b < 0) return a <= SHRT_MIN / b; // same as a * b >= SHRT_MIN |
| 1082 | return a >= SHRT_MIN / b; |
| 1083 | } |
| 1084 | |
| 1085 | // stbi__err - error |
| 1086 | // stbi__errpf - error returning pointer to float |
no outgoing calls
no test coverage detected