| 379 | } |
| 380 | |
| 381 | static bool json_append_string(char *buf, int buf_size, int *off, const char *name, |
| 382 | const char *value, bool comma) { |
| 383 | int needed = json_escaped_len(value ? value : ""); |
| 384 | char *escaped = malloc((size_t)needed + 1); |
| 385 | if (!escaped) { |
| 386 | return false; |
| 387 | } |
| 388 | int actual = cbm_json_escape(escaped, needed + 1, value ? value : ""); |
| 389 | bool ok = actual == needed && append_fmt_checked(buf, buf_size, off, "\"%s\":\"%s\"%s", name, |
| 390 | escaped, comma ? "," : ""); |
| 391 | free(escaped); |
| 392 | return ok; |
| 393 | } |
| 394 | |
| 395 | int cbm_git_context_props_json(const cbm_git_context_t *ctx, char *buf, int buf_size) { |
| 396 | if (!ctx || !buf || buf_size <= 0) { |
no test coverage detected