prevent 0 length allocation in js_worker_postMessage
This commit is contained in:
parent
e17cb9fc7a
commit
1a5333bcb3
1 changed files with 6 additions and 4 deletions
|
@ -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;
|
||||
|
||||
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);
|
||||
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 a new issue