Commit 00f5c921 authored by dearblue's avatar dearblue

Call `va_end()` before return

The behavior when returning from a function without `va_end()` is
undefined.
parent 9174b18f
...@@ -897,7 +897,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) ...@@ -897,7 +897,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
} }
break; break;
case '|': case '|':
if (opt_skip && i == argc) return argc; if (opt_skip && i == argc) goto finish;
opt = TRUE; opt = TRUE;
break; break;
case '?': case '?':
...@@ -1004,6 +1004,8 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) ...@@ -1004,6 +1004,8 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
if (!c && argc > i) { if (!c && argc > i) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "wrong number of arguments"); mrb_raise(mrb, E_ARGUMENT_ERROR, "wrong number of arguments");
} }
finish:
va_end(ap); va_end(ap);
return i; return i;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment