| 328 | } |
| 329 | |
| 330 | static bool append_fmt_checked(char *buf, int buf_size, int *off, const char *fmt, ...) { |
| 331 | if (!buf || !off || buf_size <= 0 || *off < 0 || *off >= buf_size) { |
| 332 | return false; |
| 333 | } |
| 334 | |
| 335 | va_list ap; |
| 336 | va_start(ap, fmt); |
| 337 | int n = vsnprintf(buf + *off, (size_t)(buf_size - *off), fmt, ap); |
| 338 | va_end(ap); |
| 339 | if (n < 0 || n >= buf_size - *off) { |
| 340 | buf[buf_size - 1] = '\0'; |
| 341 | return false; |
| 342 | } |
| 343 | *off += n; |
| 344 | return true; |
| 345 | } |
| 346 | |
| 347 | static int json_escaped_len(const char *src) { |
| 348 | if (!src) { |
no outgoing calls
no test coverage detected