mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-13 09:17:20 +00:00
Enable address sanitizer
This commit is contained in:
@@ -22,6 +22,10 @@ all: $(OUT_JS)
|
||||
${LDFLAGS} \
|
||||
--bind \
|
||||
--closure 1 \
|
||||
-g2 \
|
||||
-fsanitize=address \
|
||||
-s ASAN_SHADOW_SIZE=1074790400 \
|
||||
-s ASSERTIONS=1 \
|
||||
-s ALLOW_MEMORY_GROWTH=1 \
|
||||
-s MODULARIZE=1 \
|
||||
-s 'EXPORT_NAME="$(basename $(@F))"' \
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <sanitizer/lsan_interface.h>
|
||||
|
||||
#include <emscripten/bind.h>
|
||||
#include <emscripten/val.h>
|
||||
#include "avif/avif.h"
|
||||
@@ -47,4 +49,5 @@ val decode(std::string avifimage) {
|
||||
|
||||
EMSCRIPTEN_BINDINGS(my_module) {
|
||||
function("decode", &decode);
|
||||
function("doLeakCheck", &__lsan_do_recoverable_leak_check);
|
||||
}
|
||||
|
||||
1
codecs/avif/dec/avif_dec.d.ts
vendored
1
codecs/avif/dec/avif_dec.d.ts
vendored
@@ -1,5 +1,6 @@
|
||||
interface AVIFModule extends EmscriptenWasm.Module {
|
||||
decode(data: BufferSource): ImageData | null;
|
||||
doLeakCheck(): void;
|
||||
}
|
||||
|
||||
export default function(opts: EmscriptenWasm.ModuleOpts): AVIFModule;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,3 +1,5 @@
|
||||
#include <sanitizer/lsan_interface.h>
|
||||
|
||||
#include <emscripten/bind.h>
|
||||
#include <emscripten/val.h>
|
||||
#include "avif/avif.h"
|
||||
@@ -81,4 +83,5 @@ EMSCRIPTEN_BINDINGS(my_module) {
|
||||
.field("subsample", &AvifOptions::subsample);
|
||||
|
||||
function("encode", &encode);
|
||||
function("doLeakCheck", &__lsan_do_recoverable_leak_check);
|
||||
}
|
||||
|
||||
1
codecs/avif/enc/avif_enc.d.ts
vendored
1
codecs/avif/enc/avif_enc.d.ts
vendored
@@ -2,6 +2,7 @@ import { EncodeOptions } from '../../../src/codecs/avif/encoder-meta';
|
||||
|
||||
interface AVIFModule extends EmscriptenWasm.Module {
|
||||
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array | null;
|
||||
doLeakCheck(): void;
|
||||
}
|
||||
|
||||
export default function(opts: EmscriptenWasm.ModuleOpts): AVIFModule;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -12,5 +12,6 @@ export async function decode(data: ArrayBuffer): Promise<ImageData> {
|
||||
if (!result) {
|
||||
throw new Error('Decoding error');
|
||||
}
|
||||
module.doLeakCheck();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ export async function encode(data: ImageData, options: EncodeOptions): Promise<A
|
||||
if (!result) {
|
||||
throw new Error('Encoding error');
|
||||
}
|
||||
module.doLeakCheck();
|
||||
|
||||
// wasm can’t run on SharedArrayBuffers, so we hard-cast to ArrayBuffer.
|
||||
return result.buffer as ArrayBuffer;
|
||||
|
||||
Reference in New Issue
Block a user