[v10.x backport] n-api: handle reference delete before finalize by mhdawson · Pull Request #25574 · nodejs/node (original) (raw)

Backport of #24494

Crashes were reported during finalization due to
the memory for a reference being deleted and the
finalizer running after the deletion.

This change ensures the deletion of the memory for
the reference only occurs after the finalizer has run.

Fixes: nodejs/node-addon-api#393

Backport-PR-URL: #25574
PR-URL: #24494
Reviewed-By: Anna Henningsen anna@addaleax.net
Reviewed-By: Franziska Hinkelmann franziska.hinkelmann@gmail.com
Reviewed-By: Refael Ackermann refack@gmail.com

Checklist