| 338 | } |
| 339 | |
| 340 | static bool append_fmt_checked(char *buf, int buf_size, int *off, const char *fmt, ...) { |
| 341 | if (!buf || !off || buf_size <= 0 || *off < 0 || *off >= buf_size) { |
| 342 | return false; |
| 343 | } |
| 344 | |
| 345 | va_list ap; |
| 346 | va_start(ap, fmt); |
| 347 | int n = vsnprintf(buf + *off, (size_t)(buf_size - *off), fmt, ap); |
| 348 | va_end(ap); |
| 349 | if (n < 0 || n >= buf_size - *off) { |
| 350 | buf[buf_size - 1] = '\0'; |
| 351 | return false; |
| 352 | } |
| 353 | *off += n; |
| 354 | return true; |
| 355 | } |
| 356 | |
| 357 | static int json_escaped_len(const char *src) { |
| 358 | if (!src) { |
no outgoing calls
no test coverage detected