vbscript: Don't abort when trying to TRACE() functions with many arguments.

__wine_dbg_output accumulates the output characters in a debug_info
structure, flushing it when it encounters '\n'. If debug_info plus the
new string exceed 1024 characters, append_output will print

> wine_dbg_output: debugstr buffer overflow

and then crash the process via abort().

wine_dbgstr_variant limits the length printed for any individual argument,
but a function with multiple parameters can still plausibly exceed 1024.

Fixed by formatting the TRACE for each argument on a separate line,
as similar places (like oleaut32/typelib.c:dump_DispParms) do.
This commit is contained in:
Kevin Puetz 2022-09-28 17:53:36 -05:00 committed by Alexandre Julliard
parent e24791268d
commit 0fb2d0f04e
2 changed files with 7 additions and 3 deletions

View file

@ -2422,7 +2422,7 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd
heap_pool_init(&exec.heap);
TRACE("%s(", debugstr_w(func->name));
TRACE("%s args=%u\n", debugstr_w(func->name),func->arg_cnt);
if(func->arg_cnt) {
VARIANT *v;
unsigned i;
@ -2435,7 +2435,7 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd
for(i=0; i < func->arg_cnt; i++) {
v = get_arg(dp, i);
TRACE("%s%s", i ? ", " : "", debugstr_variant(v));
TRACE(" [%d] %s\n", i, debugstr_variant(v));
if(V_VT(v) == (VT_VARIANT|VT_BYREF)) {
if(func->args[i].by_ref)
exec.args[i] = *v;
@ -2452,7 +2452,6 @@ HRESULT exec_script(script_ctx_t *ctx, BOOL extern_caller, function_t *func, vbd
}else {
exec.args = NULL;
}
TRACE(")\n");
if(func->var_cnt) {
exec.vars = heap_alloc_zero(func->var_cnt * sizeof(VARIANT));

View file

@ -777,6 +777,11 @@ sub testSpaceError()
end sub
call testSpaceError()
function strlength(s1, s2, s3, s4, s5)
strlength = Len(s1 & s2 & s3 & s4 & s5)
end function
Call ok(strlength(String(500, "a"), String(500, "b"), String(500, "c"), String(500, "d"), String(500, "e")) = 500*5, "strlength(...) = 500*5")
sub test_string(cnt, char, exp)
call ok(String(cnt, char) = exp, "String(" & cnt & ", """ & char & """ = """ & _
String(cnt, char) & """ expected """ & exp & """")