From 56fef61c6665a0bbc9df937afd0d0a1aaac55963 Mon Sep 17 00:00:00 2001 From: DerSkythe <31771569+derskythe@users.noreply.github.com> Date: Wed, 31 Jul 2024 21:12:26 +0400 Subject: [PATCH] fix: Ensure proper closure of variadic function in `mjs_array` (#3798) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The changes ensure that the `va_end` function is always called after `c_vsnprintf` in `mjs_array.c` Co-authored-by: あく --- lib/mjs/mjs_array.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/mjs/mjs_array.c b/lib/mjs/mjs_array.c index c74487d65..9230436e8 100644 --- a/lib/mjs/mjs_array.c +++ b/lib/mjs/mjs_array.c @@ -19,8 +19,11 @@ static int v_sprintf_s(char* buf, size_t size, const char* fmt, ...) { size_t n; va_list ap; + va_start(ap, fmt); n = c_vsnprintf(buf, size, fmt, ap); + va_end(ap); + if(n > size) { return size; }