BUGFIX: Fix potential double-free in atExit() (#655)

Fixes #654
This commit is contained in:
David Walker 2023-06-30 15:15:37 -07:00 committed by GitHub
parent 48e7bd6471
commit babefc5477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -51,6 +51,10 @@ function stopAndCleanUpWorkerScript(ws: WorkerScript): void {
} catch (e: unknown) {
handleUnknownError(e, ws, "Error running atExit function.\n\n");
}
if (ws.env.stopFlag) {
// If atExit() kills the script, we'll already be stopped, don't stop again.
return;
}
}
ws.env.stopFlag = true;
removeWorkerScript(ws);