From cedcf2d681f08f8bed8ef8f3a8bd4e67d4a04c77 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Mon, 25 Nov 2024 13:05:18 +0100 Subject: [PATCH] error.c: call `va_end` before jumping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The man page is clear that every `va_start` call MUST be succeeded by the corresponding `va_end` call. So `rb_raise` can't call `rb_exc_raise` before `va_end`, otherwise `va_end` is never called. Co-Authored-By: Étienne Barrié --- error.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/error.c b/error.c index 384a56f5df..e78071c686 100644 --- a/error.c +++ b/error.c @@ -3632,12 +3632,13 @@ rb_vraise(VALUE exc, const char *fmt, va_list ap) } void -rb_raise(VALUE exc, const char *fmt, ...) +rb_raise(VALUE exc_class, const char *fmt, ...) { va_list args; va_start(args, fmt); - rb_vraise(exc, fmt, args); + VALUE exc = rb_exc_new3(exc_class, rb_vsprintf(fmt, args)); va_end(args); + rb_exc_raise(exc); } NORETURN(static void raise_loaderror(VALUE path, VALUE mesg));