aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bun.zig9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/bun.zig b/src/bun.zig
index 148244df5..eec6a4ecc 100644
--- a/src/bun.zig
+++ b/src/bun.zig
@@ -386,10 +386,13 @@ pub inline fn range(comptime min: anytype, comptime max: anytype) [max - min]usi
pub fn copy(comptime Type: type, dest: []Type, src: []const Type) void {
if (comptime Environment.allow_assert) std.debug.assert(dest.len >= src.len);
- if (@ptrToInt(src.ptr) == @ptrToInt(dest.ptr)) return;
+ if (@ptrToInt(src.ptr) == @ptrToInt(dest.ptr) or src.len == 0) return;
- var input: []const u8 = std.mem.sliceAsBytes(src);
- var output: []u8 = std.mem.sliceAsBytes(dest);
+ const input: []const u8 = std.mem.sliceAsBytes(src);
+ const output: []u8 = std.mem.sliceAsBytes(dest);
+
+ std.debug.assert(input.len > 0);
+ std.debug.assert(output.len > 0);
// if input.len overlaps with output.len, we need to copy backwards
const overlaps = isSliceInBuffer(input, output) or isSliceInBuffer(output, input);