* Return a * b if it would not overflow. * Die with an "out of memory" error if it would. */
| 984 | * Die with an "out of memory" error if it would. |
| 985 | */ |
| 986 | static size_t |
| 987 | xmul (size_t a, size_t b) |
| 988 | { |
| 989 | #if defined(__GNUC__) && __GNUC__ >= 5 |
| 990 | size_t result; |
| 991 | if (__builtin_mul_overflow (a, b, &result)) |
| 992 | die_oom (); |
| 993 | return result; |
| 994 | #else |
| 995 | if (b != 0 && a > SIZE_MAX / b) |
| 996 | die_oom (); |
| 997 | |
| 998 | return a * b; |
| 999 | #endif |
| 1000 | } |
| 1001 | |
| 1002 | void |
| 1003 | strappend (StringBuilder *dest, const char *src) |
no test coverage detected