Skip to content

Commit 1021aa2

Browse files
committed
Fix memory leaks
1 parent 003d5d1 commit 1021aa2

File tree

4 files changed

+4
-1
lines changed

4 files changed

+4
-1
lines changed

codecs/qoi/dec/qoi_dec.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ val decode(std::string qoiimage) {
2020
val result = ImageData.new_(
2121
Uint8ClampedArray.new_(typed_memory_view(4 * decodedWidth * decodedHeight, rgba)),
2222
decodedWidth, decodedHeight);
23+
free(rgba);
2324

2425
return result;
2526
}

codecs/qoi/dec/qoi_dec.wasm

4 Bytes
Binary file not shown.

codecs/qoi/enc/qoi_enc.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ val encode(std::string buffer, int width, int height, QoiOptions options) {
1818
desc.channels = 4;
1919
desc.colorspace = QOI_SRGB;
2020

21-
void* encodedData = qoi_encode(buffer.c_str(), &desc, &compressedSizeInBytes);
21+
uint8_t* encodedData = (uint8_t*)qoi_encode(buffer.c_str(), &desc, &compressedSizeInBytes);
2222
if (encodedData == NULL)
2323
return val::null();
2424

2525
auto js_result =
2626
Uint8Array.new_(typed_memory_view(compressedSizeInBytes, (const uint8_t*)encodedData));
27+
free(encodedData);
28+
2729
return js_result;
2830
}
2931

codecs/qoi/enc/qoi_enc.wasm

8 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)