mirror of
https://github.com/bellard/quickjs.git
synced 2024-11-22 21:58:12 +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);
|
memcpy(msg->data, data, data_len);
|
||||||
msg->data_len = data_len;
|
msg->data_len = data_len;
|
||||||
|
|
||||||
msg->sab_tab = malloc(sizeof(msg->sab_tab[0]) * sab_tab_len);
|
if (sab_tab_len > 0) {
|
||||||
if (!msg->sab_tab)
|
msg->sab_tab = malloc(sizeof(msg->sab_tab[0]) * sab_tab_len);
|
||||||
goto fail;
|
if (!msg->sab_tab)
|
||||||
memcpy(msg->sab_tab, sab_tab, sizeof(msg->sab_tab[0]) * sab_tab_len);
|
goto fail;
|
||||||
|
memcpy(msg->sab_tab, sab_tab, sizeof(msg->sab_tab[0]) * sab_tab_len);
|
||||||
|
}
|
||||||
msg->sab_tab_len = sab_tab_len;
|
msg->sab_tab_len = sab_tab_len;
|
||||||
|
|
||||||
js_free(ctx, data);
|
js_free(ctx, data);
|
||||||
|
Loading…
Reference in New Issue
Block a user