mirror of
https://github.com/bellard/quickjs.git
synced 2024-11-22 13:48:11 +08:00
prevent 0 length allocation in js_worker_postMessage
This commit is contained in:
parent
e17cb9fc7a
commit
1a5333bcb3
@ -3527,10 +3527,12 @@ static JSValue js_worker_postMessage(JSContext *ctx, JSValueConst this_val,
|
||||
memcpy(msg->data, data, data_len);
|
||||
msg->data_len = data_len;
|
||||
|
||||
if (sab_tab_len > 0) {
|
||||
msg->sab_tab = malloc(sizeof(msg->sab_tab[0]) * sab_tab_len);
|
||||
if (!msg->sab_tab)
|
||||
goto fail;
|
||||
memcpy(msg->sab_tab, sab_tab, sizeof(msg->sab_tab[0]) * sab_tab_len);
|
||||
}
|
||||
msg->sab_tab_len = sab_tab_len;
|
||||
|
||||
js_free(ctx, data);
|
||||
|
Loading…
Reference in New Issue
Block a user