mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
fix: Prevent segfault when using add.Module()
This duplicates the source file string (as is done in other places such as `addAssemblyFile()`) in order to prevent a segfault when the supplied string is freed by the caller. This is still seen when the caller makes use of a defer statement.
This commit is contained in:
parent
f29302f915
commit
280140595f
@ -869,7 +869,7 @@ pub fn createModule(b: *Build, options: CreateModuleOptions) *Module {
|
||||
const module = b.allocator.create(Module) catch @panic("OOM");
|
||||
module.* = .{
|
||||
.builder = b,
|
||||
.source_file = options.source_file,
|
||||
.source_file = options.source_file.dupe(b),
|
||||
.dependencies = moduleDependenciesToArrayHashMap(b.allocator, options.dependencies),
|
||||
};
|
||||
return module;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user