Skip to content
Merged
Changes from 1 commit
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
9 changes: 7 additions & 2 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