Skip to content

Commit

Permalink
Add a few more checks for isNumber()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarred-Sumner committed Mar 8, 2023
1 parent e838f8b commit c6f0140
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/bun.js/webcore/streams.zig
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,8 @@ pub const StreamStart = union(Tag) {
}

if (value.get(globalThis, "chunkSize")) |chunkSize| {
return .{ .chunk_size = @intCast(Blob.SizeType, @truncate(i52, chunkSize.toInt64())) };
if (chunkSize.isNumber())
return .{ .chunk_size = @intCast(Blob.SizeType, @truncate(i52, chunkSize.toInt64())) };
}

return .{ .empty = {} };
Expand Down Expand Up @@ -432,8 +433,10 @@ pub const StreamStart = union(Tag) {
}

if (value.get(globalThis, "highWaterMark")) |chunkSize| {
empty = false;
chunk_size = @intCast(JSC.WebCore.Blob.SizeType, @max(0, @truncate(i51, chunkSize.toInt64())));
if (chunkSize.isNumber()) {
empty = false;
chunk_size = @intCast(JSC.WebCore.Blob.SizeType, @max(0, @truncate(i51, chunkSize.toInt64())));
}
}

if (!empty) {
Expand All @@ -450,7 +453,8 @@ pub const StreamStart = union(Tag) {
var chunk_size: JSC.WebCore.Blob.SizeType = 0;

if (value.get(globalThis, "highWaterMark")) |chunkSize| {
chunk_size = @intCast(JSC.WebCore.Blob.SizeType, @max(0, @truncate(i51, chunkSize.toInt64())));
if (chunkSize.isNumber())
chunk_size = @intCast(JSC.WebCore.Blob.SizeType, @max(0, @truncate(i51, chunkSize.toInt64())));
}

if (value.get(globalThis, "path")) |path| {
Expand Down Expand Up @@ -485,8 +489,10 @@ pub const StreamStart = union(Tag) {
var chunk_size: JSC.WebCore.Blob.SizeType = 2048;

if (value.get(globalThis, "highWaterMark")) |chunkSize| {
empty = false;
chunk_size = @intCast(JSC.WebCore.Blob.SizeType, @max(256, @truncate(i51, chunkSize.toInt64())));
if (chunkSize.isNumber()) {
empty = false;
chunk_size = @intCast(JSC.WebCore.Blob.SizeType, @max(256, @truncate(i51, chunkSize.toInt64())));
}
}

if (!empty) {
Expand Down

0 comments on commit c6f0140

Please sign in to comment.