@@ -1464,32 +1464,16 @@ addToLibrary({
14641464 } ,
14651465
14661466#if USE_ASAN || USE_LSAN || UBSAN_RUNTIME
1467- // When lsan or asan is enabled withBuiltinMalloc temporarily replaces calls
1468- // to malloc, calloc, free, and memalign.
1469- $withBuiltinMalloc__deps : [
1470- 'malloc' , 'calloc' , 'free' , 'memalign' , 'realloc' ,
1471- 'emscripten_builtin_malloc' , 'emscripten_builtin_free' , 'emscripten_builtin_memalign' , 'emscripten_builtin_calloc' , 'emscripten_builtin_realloc'
1472- ] ,
1473- $withBuiltinMalloc__docs : '/** @suppress{checkTypes} */' ,
1474- $withBuiltinMalloc : ( func ) = > {
1475- var prev_malloc = typeof _malloc != 'undefined' ? _malloc : undefined ;
1476- var prev_calloc = typeof _calloc != 'undefined' ? _calloc : undefined ;
1477- var prev_memalign = typeof _memalign != 'undefined' ? _memalign : undefined ;
1478- var prev_free = typeof _free != 'undefined' ? _free : undefined ;
1479- var prev_realloc = typeof _realloc != 'undefined' ? _realloc : undefined ;
1480- _malloc = _emscripten_builtin_malloc ;
1481- _calloc = _emscripten_builtin_calloc ;
1482- _memalign = _emscripten_builtin_memalign ;
1483- _free = _emscripten_builtin_free ;
1484- _realloc = _emscripten_builtin_realloc ;
1467+ // When lsan is enabled noLeakCheck will temporarily disable leak checking
1468+ // for the duration of the function.
1469+ $noLeakCheck__deps : [ '__lsan_enable' , '__lsan_disable' ] ,
1470+ $noLeakCheck__docs : '/** @suppress{checkTypes} */' ,
1471+ $noLeakCheck : ( func ) = > {
1472+ if ( runtimeInitialized ) ___lsan_disable ( ) ;
14851473 try {
14861474 return func ( ) ;
14871475 } finally {
1488- _malloc = prev_malloc ;
1489- _calloc = prev_calloc ;
1490- _memalign = prev_memalign ;
1491- _free = prev_free ;
1492- _realloc = prev_realloc ;
1476+ if ( runtimeInitialized ) ___lsan_enable ( ) ;
14931477 }
14941478 } ,
14951479
@@ -1501,11 +1485,9 @@ addToLibrary({
15011485 return ENVIRONMENT_IS_NODE && process . stderr . isTTY ;
15021486 } ,
15031487
1504- _emscripten_sanitizer_get_option__deps : [ '$withBuiltinMalloc' , '$ stringToNewUTF8', '$UTF8ToString' ] ,
1488+ _emscripten_sanitizer_get_option__deps : [ '$stringToNewUTF8' , '$UTF8ToString' ] ,
15051489 _emscripten_sanitizer_get_option__sig : 'pp ',
1506- _emscripten_sanitizer_get_option : ( name ) => {
1507- return withBuiltinMalloc ( ( ) => stringToNewUTF8 ( Module [ UTF8ToString ( name ) ] || "" ) ) ;
1508- } ,
1490+ _emscripten_sanitizer_get_option : ( name ) = > stringToNewUTF8 ( Module [ UTF8ToString ( name ) ] || '' ) ,
15091491#endif
15101492
15111493 $readEmAsmArgsArray : [ ] ,
0 commit comments