Skip to content

Make images smaller using best-in-class codecs, right in the browser.

JavaScript

Fix use-after-free in imagequant

Ingvar Stepanyan4fc18de5f9ae
diff --git a/src/codecs/imagequant/processor.ts b/src/codecs/imagequant/processor.ts
index be6f4da2..a8b9ae3b 100644
--- a/src/codecs/imagequant/processor.ts
+++ b/src/codecs/imagequant/processor.ts
@@ -15,7 +15,9 @@ export async function process(data: ImageData, opts: QuantizeOptions): Promise<I
:
module.quantize(data.data, data.width, data.height, opts.maxNumColors, opts.dither);
+ const imgData = new ImageData(new Uint8ClampedArray(result.buffer), result.width, result.height);
+
module.free_result();
- return new ImageData(new Uint8ClampedArray(result.buffer), result.width, result.height);
+ return imgData;
}