aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-07-22 22:20:10 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-22 22:20:10 -0700
commite2e44661c2e5bb96ef70df4e6e68b05e19ec36c7 (patch)
tree076ba1e42097b42edb66eca2530c10e54078665a
parent601fd3ead532b66763d3c57a5c0b9d52c59c1312 (diff)
downloadbun-e2e44661c2e5bb96ef70df4e6e68b05e19ec36c7.tar.gz
bun-e2e44661c2e5bb96ef70df4e6e68b05e19ec36c7.tar.zst
bun-e2e44661c2e5bb96ef70df4e6e68b05e19ec36c7.zip
Explicitly ref/unref blobs before extracting the value (#3755)
* Explicitly ref/unref blobs before extracting the value * :scissors: --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
-rw-r--r--src/bun.js/webcore/blob.zig36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig
index e81d1f8f6..7036babfb 100644
--- a/src/bun.js/webcore/blob.zig
+++ b/src/bun.js/webcore/blob.zig
@@ -790,6 +790,10 @@ pub const Blob = struct {
}
}
+ var input_store: ?*Store = if (path_or_blob == .blob) path_or_blob.blob.store else null;
+ if (input_store) |st| st.ref();
+ defer if (input_store) |st| st.deref();
+
var needs_async = false;
if (data.isString()) {
@@ -973,6 +977,17 @@ pub const Blob = struct {
};
};
+ var destination_store = destination_blob.store;
+ if (destination_store) |store| {
+ store.ref();
+ }
+
+ defer {
+ if (destination_store) |store| {
+ store.deref();
+ }
+ }
+
return writeFileWithSourceDestination(ctx, &source_blob, &destination_blob);
}
@@ -2503,6 +2518,9 @@ pub const Blob = struct {
globalThis: *JSC.JSGlobalObject,
_: *JSC.CallFrame,
) callconv(.C) JSC.JSValue {
+ var store = this.store;
+ if (store) |st| st.ref();
+ defer if (store) |st| st.deref();
return promisified(this.toString(globalThis, .clone), globalThis);
}
@@ -2510,6 +2528,9 @@ pub const Blob = struct {
this: *Blob,
globalObject: *JSC.JSGlobalObject,
) JSC.JSValue {
+ var store = this.store;
+ if (store) |st| st.ref();
+ defer if (store) |st| st.deref();
return promisified(this.toString(globalObject, .transfer), globalObject);
}
@@ -2518,6 +2539,10 @@ pub const Blob = struct {
globalThis: *JSC.JSGlobalObject,
_: *JSC.CallFrame,
) callconv(.C) JSC.JSValue {
+ var store = this.store;
+ if (store) |st| st.ref();
+ defer if (store) |st| st.deref();
+
return promisified(this.toJSON(globalThis, .share), globalThis);
}
@@ -2525,6 +2550,10 @@ pub const Blob = struct {
this: *Blob,
globalThis: *JSC.JSGlobalObject,
) JSC.JSValue {
+ var store = this.store;
+ if (store) |st| st.ref();
+ defer if (store) |st| st.deref();
+
return promisified(this.toArrayBuffer(globalThis, .transfer), globalThis);
}
@@ -2533,6 +2562,9 @@ pub const Blob = struct {
globalThis: *JSC.JSGlobalObject,
_: *JSC.CallFrame,
) callconv(.C) JSValue {
+ var store = this.store;
+ if (store) |st| st.ref();
+ defer if (store) |st| st.deref();
return promisified(this.toArrayBuffer(globalThis, .clone), globalThis);
}
@@ -2541,6 +2573,10 @@ pub const Blob = struct {
globalThis: *JSC.JSGlobalObject,
_: *JSC.CallFrame,
) callconv(.C) JSValue {
+ var store = this.store;
+ if (store) |st| st.ref();
+ defer if (store) |st| st.deref();
+
return promisified(this.toFormData(globalThis, .temporary), globalThis);
}