| 417 | } |
| 418 | |
| 419 | static bool json_append_string(char *buf, int buf_size, int *off, const char *name, |
| 420 | const char *value, bool comma) { |
| 421 | int needed = json_escaped_len(value ? value : ""); |
| 422 | char *escaped = malloc((size_t)needed + 1); |
| 423 | if (!escaped) { |
| 424 | return false; |
| 425 | } |
| 426 | int actual = cbm_json_escape(escaped, needed + 1, value ? value : ""); |
| 427 | bool ok = actual == needed && append_fmt_checked(buf, buf_size, off, "\"%s\":\"%s\"%s", name, |
| 428 | escaped, comma ? "," : ""); |
| 429 | free(escaped); |
| 430 | return ok; |
| 431 | } |
| 432 | |
| 433 | int cbm_git_context_props_json(const cbm_git_context_t *ctx, char *buf, int buf_size) { |
| 434 | if (!ctx || !buf || buf_size <= 0) { |
no test coverage detected