Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation: read entire source into a buffer before processing it #520

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Compilation: use an errdefer compile error for documentation instead …
…of a comment
  • Loading branch information
ehaas committed Oct 9, 2023
commit ca2b917686e227ccb8a27ff81f71c654099ff796
4 changes: 1 addition & 3 deletions src/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1084,10 +1084,8 @@ pub fn addSourceFromOwnedBuffer(comp: *Compilation, buf: []u8, path: []const u8,
const splice_locs = try splice_list.toOwnedSlice();
errdefer comp.gpa.free(splice_locs);

// Important: do not perform any possibly-failing operations in this function after this realloc.
// Otherwise errdefers in callers will possibly free the realloced slice using the original len
// instead of the new
if (i != contents.len) contents = try comp.gpa.realloc(contents, i);
errdefer @compileError("errdefers in callers would possibly free the realloced slice using the original len");

var source = Source{
.id = source_id,
Expand Down