Skip to content

Commit

Permalink
Compilation: fix IES for addSourceFromBuffer
Browse files Browse the repository at this point in the history
Trick the compiler into thinking error.StreamTooLong can be returned
from addSourceFromBuffer in 32-bit builds
  • Loading branch information
ehaas committed Oct 10, 2023
1 parent ca2b917 commit 6ee955f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ pub fn addSourceFromOwnedBuffer(comp: *Compilation, buf: []u8, path: []const u8,
/// the allocation, please use `addSourceFromOwnedBuffer`
pub fn addSourceFromBuffer(comp: *Compilation, path: []const u8, buf: []const u8) !Source {
if (comp.sources.get(path)) |some| return some;
if (buf.len > std.math.maxInt(u32)) return error.StreamTooLong;
if (@as(u64, buf.len) > std.math.maxInt(u32)) return error.StreamTooLong;

const contents = try comp.gpa.dupe(u8, buf);
errdefer comp.gpa.free(contents);
Expand Down

0 comments on commit 6ee955f

Please sign in to comment.