Fix 2 memory leaks in zlib from #11770 (#13787)

This commit is contained in:
Jarred Sumner
2024-09-07 02:12:09 -07:00
committed by GitHub
parent 084734db64
commit 08103aa7ae

View File

@@ -128,9 +128,10 @@ pub const ZlibEncoder = struct {
this.stream.flush = @enumFromInt(int);
}
const input_to_queue = JSC.Node.BlobOrStringOrBuffer.fromJSWithEncodingValueMaybeAsync(globalThis, bun.default_allocator, input, optional_encoding, true) orelse {
const input_to_queue = JSC.Node.BlobOrStringOrBuffer.fromJSWithEncodingValueMaybeAsync(globalThis, bun.default_allocator, input, optional_encoding, false) orelse {
return globalThis.throwInvalidArgumentTypeValue("buffer", "string or an instance of Buffer, TypedArray, DataView, or ArrayBuffer", input);
};
defer input_to_queue.deinit();
if (is_last)
this.has_called_end = true;
@@ -184,9 +185,10 @@ pub const ZlibEncoder = struct {
};
if (globalThis.hasException()) return .zero;
const input_to_queue = JSC.Node.BlobOrStringOrBuffer.fromJSWithEncodingValueMaybeAsync(globalThis, bun.default_allocator, input, optional_encoding, true) orelse {
const input_to_queue = JSC.Node.BlobOrStringOrBuffer.fromJSWithEncodingValueMaybeAsync(globalThis, bun.default_allocator, input, optional_encoding, false) orelse {
return globalThis.throwInvalidArgumentTypeValue("buffer", "string or an instance of Buffer, TypedArray, DataView, or ArrayBuffer", input);
};
defer input_to_queue.deinit();
if (is_last)
this.has_called_end = true;
@@ -611,10 +613,10 @@ pub const ZlibDecoder = struct {
};
if (globalThis.hasException()) return .zero;
const input_to_queue = JSC.Node.BlobOrStringOrBuffer.fromJSWithEncodingValueMaybeAsync(globalThis, bun.default_allocator, input, optional_encoding, true) orelse {
const input_to_queue = JSC.Node.BlobOrStringOrBuffer.fromJSWithEncodingValue(globalThis, bun.default_allocator, input, optional_encoding) orelse {
return globalThis.throwInvalidArgumentTypeValue("buffer", "string or an instance of Buffer, TypedArray, DataView, or ArrayBuffer", input);
};
defer input_to_queue.deinit();
if (is_last)
this.has_called_end = true;