return 1 if the sum is valid, 0 on overflow. negative terms are considered invalid.
| 1025 | // return 1 if the sum is valid, 0 on overflow. |
| 1026 | // negative terms are considered invalid. |
| 1027 | static int stbi__addsizes_valid(int a, int b) { |
| 1028 | if (b < 0) |
| 1029 | return 0; |
| 1030 | // now 0 <= b <= INT_MAX, hence also |
| 1031 | // 0 <= INT_MAX - b <= INTMAX. |
| 1032 | // And "a + b <= INT_MAX" (which might overflow) is the |
| 1033 | // same as a <= INT_MAX - b (no overflow) |
| 1034 | return a <= INT_MAX - b; |
| 1035 | } |
| 1036 | |
| 1037 | // returns 1 if the product is valid, 0 on overflow. |
| 1038 | // negative factors are considered invalid. |
no outgoing calls
no test coverage detected