neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit ad22d0ace9965907a83088fb52dd407b92222992
parent 0c49167490c07f657da2fd7c0e07c3956fcee758
Author: skewb1k <skewb1kunix@gmail.com>
Date:   Mon,  8 Sep 2025 01:45:34 +0300

fix(cjson): fix `strbuf_set_length` incorrectness #35565

`strbuf_set_length` was incorrectly updating
length with `+=` instead of assignment.

Also syncs minor updates with upstream.
Diffstat:
Msrc/cjson/fpconv.c | 2+-
Msrc/cjson/strbuf.c | 7++++---
Msrc/cjson/strbuf.h | 2+-
3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/cjson/fpconv.c b/src/cjson/fpconv.c @@ -130,7 +130,7 @@ double fpconv_strtod(const char *nptr, char **endptr) /* Duplicate number into buffer */ if (buflen >= FPCONV_G_FMT_BUFSIZE) { /* Handle unusually large numbers */ - buf = malloc(buflen + 1); + buf = (char *)malloc(buflen + 1); if (!buf) { fprintf(stderr, "Out of memory"); abort(); diff --git a/src/cjson/strbuf.c b/src/cjson/strbuf.c @@ -39,7 +39,7 @@ static void die(const char *fmt, ...) va_end(arg); fprintf(stderr, "\n"); - exit(-1); + abort(); } void strbuf_init(strbuf_t *s, size_t len) @@ -51,7 +51,7 @@ void strbuf_init(strbuf_t *s, size_t len) else size = len + 1; /* \0 terminator */ if (size < len) - die("Overflow, len %zu", len); + die("Overflow, len: %zu", len); s->buf = NULL; s->size = size; s->length = 0; @@ -132,7 +132,7 @@ static size_t calculate_new_size(strbuf_t *s, size_t len) /* Ensure there is room for optional NULL termination */ reqsize = len + 1; if (reqsize < len) - die("Overflow, len %zu", len); + die("Overflow, len: %zu", len); /* If the user has requested to shrink the buffer, do it exactly */ if (s->size > reqsize) @@ -194,5 +194,6 @@ void strbuf_append_string(strbuf_t *s, const char *str) } } + /* vi:ai et sw=4 ts=4: */ diff --git a/src/cjson/strbuf.h b/src/cjson/strbuf.h @@ -103,7 +103,7 @@ static inline char *strbuf_empty_ptr(strbuf_t *s) static inline void strbuf_set_length(strbuf_t *s, int len) { - s->length += len; + s->length = len; } static inline void strbuf_extend_length(strbuf_t *s, size_t len)