Skip to content

Fix __cxa_find_matching_catch's memory leak #8947

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 6 commits into from
Jul 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/library_exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,16 @@ var LibraryExceptions = {

var pointer = {{{ exportedAsmFunc('___cxa_is_pointer_type') }}}(throwntype);
// can_catch receives a **, add indirection
if (!___cxa_find_matching_catch.buffer) ___cxa_find_matching_catch.buffer = _malloc(4);
#if EXCEPTION_DEBUG
out("can_catch on " + [thrown]);
#endif
{{{ makeSetValue('___cxa_find_matching_catch.buffer', '0', 'thrown', '*') }}};
thrown = ___cxa_find_matching_catch.buffer;
#if DISABLE_EXCEPTION_CATCHING == 1
var buffer = 0;
#else
var buffer = {{{ makeStaticAlloc(4) }}};
#endif
{{{ makeSetValue('buffer', '0', 'thrown', '*') }}};
thrown = buffer;
// The different catch blocks are denoted by different types.
// Due to inheritance, those types may not precisely match the
// type of the thrown object. Find one which matches, and
Expand Down