| 376 | } |
| 377 | |
| 378 | static bool append_fmt_checked(char *buf, int buf_size, int *off, const char *fmt, ...) { |
| 379 | if (!buf || !off || buf_size <= 0 || *off < 0 || *off >= buf_size) { |
| 380 | return false; |
| 381 | } |
| 382 | |
| 383 | va_list ap; |
| 384 | va_start(ap, fmt); |
| 385 | int n = vsnprintf(buf + *off, (size_t)(buf_size - *off), fmt, ap); |
| 386 | va_end(ap); |
| 387 | if (n < 0 || n >= buf_size - *off) { |
| 388 | buf[buf_size - 1] = '\0'; |
| 389 | return false; |
| 390 | } |
| 391 | *off += n; |
| 392 | return true; |
| 393 | } |
| 394 | |
| 395 | static int json_escaped_len(const char *src) { |
| 396 | if (!src) { |
no outgoing calls
no test coverage detected