diff options
author | 2023-02-25 18:48:59 -0800 | |
---|---|---|
committer | 2023-02-25 18:48:59 -0800 | |
commit | 2dd484c18089ea86831eeb5e0bd02f29da564f55 (patch) | |
tree | ca47ddeb25d5870c9ed04358a0443d0e027a8d65 | |
parent | 58685638e20e30ca4b1b2f9713ee82482ea39cc2 (diff) | |
download | bun-2dd484c18089ea86831eeb5e0bd02f29da564f55.tar.gz bun-2dd484c18089ea86831eeb5e0bd02f29da564f55.tar.zst bun-2dd484c18089ea86831eeb5e0bd02f29da564f55.zip |
Add more assertions
-rw-r--r-- | src/bun.zig | 9 |
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); |