Func: fix memory leaks in check_built_in_call()

All error branches leak the `fmt_str_arg->Eval(0)` return value.
This commit is contained in:
Max Kellermann 2020-02-21 18:52:12 +01:00
parent 6c263cbce5
commit e32a9a61f6

View file

@ -828,6 +828,7 @@ bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
if ( ! *fmt_str ) if ( ! *fmt_str )
{ {
Unref(fmt_str_val);
call->Error("format string ends with bare '%'"); call->Error("format string ends with bare '%'");
return false; return false;
} }
@ -839,11 +840,13 @@ bool check_built_in_call(BuiltinFunc* f, CallExpr* call)
if ( args.length() != num_fmt + 1 ) if ( args.length() != num_fmt + 1 )
{ {
Unref(fmt_str_val);
call->Error("mismatch between format string to fmt() and number of arguments passed"); call->Error("mismatch between format string to fmt() and number of arguments passed");
return false; return false;
} }
} }
Unref(fmt_str_val);
return true; return true;
} }