Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -5161,21 +5161,26 @@ JSValue JS_NewArrayFrom(JSContext *ctx, int count, const JSValue *values)
{
JSObject *p;
JSValue obj;
int i;

obj = JS_NewArray(ctx);
if (JS_IsException(obj))
return JS_EXCEPTION;
goto exception;
if (count > 0) {
p = JS_VALUE_GET_OBJ(obj);
if (expand_fast_array(ctx, p, count)) {
JS_FreeValue(ctx, obj);
return JS_EXCEPTION;
goto exception;
}
p->u.array.count = count;
p->prop[0].u.value = js_int32(count);
memcpy(p->u.array.u.values, values, count * sizeof(*values));
}
return obj;
exception:
for (i = 0; i < count; i++)
JS_FreeValue(ctx, values[i]);
return JS_EXCEPTION;
}

JSValue JS_NewObject(JSContext *ctx)
Expand Down Expand Up @@ -16575,9 +16580,9 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValueConst func_obj,
pc += 2;
call_argv = sp - call_argc;
ret_val = JS_NewArrayFrom(ctx, call_argc, call_argv);
sp -= call_argc;
if (unlikely(JS_IsException(ret_val)))
goto exception;
sp -= call_argc;
*sp++ = ret_val;
}
BREAK;
Expand Down