aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-09-18 10:25:37 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-09-18 10:25:57 -0400
commit1fc2019031ef427e02acc88d7ce1c15372556c4d (patch)
tree452f5f81349b1858d3b3790038402784bac75310 /src/ir.cpp
parent93ff5024a4186d0067df969d403d311ac978996c (diff)
downloadzig-1fc2019031ef427e02acc88d7ce1c15372556c4d.tar.gz
zig-1fc2019031ef427e02acc88d7ce1c15372556c4d.zip
fix @embedFile reading garbage memory
closes #1547
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 5da0008e03..8303b0fc85 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -18187,17 +18187,18 @@ static ZigType *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionE
&source_dir_path,
rel_file_path,
};
- Buf file_path = os_path_resolve(resolve_paths, 2);
+ Buf *file_path = buf_alloc();
+ *file_path = os_path_resolve(resolve_paths, 2);
// load from file system into const expr
Buf *file_contents = buf_alloc();
int err;
- if ((err = file_fetch(ira->codegen, &file_path, file_contents))) {
+ if ((err = file_fetch(ira->codegen, file_path, file_contents))) {
if (err == ErrorFileNotFound) {
- ir_add_error(ira, instruction->name, buf_sprintf("unable to find '%s'", buf_ptr(&file_path)));
+ ir_add_error(ira, instruction->name, buf_sprintf("unable to find '%s'", buf_ptr(file_path)));
return ira->codegen->builtin_types.entry_invalid;
} else {
- ir_add_error(ira, instruction->name, buf_sprintf("unable to open '%s': %s", buf_ptr(&file_path), err_str(err)));
+ ir_add_error(ira, instruction->name, buf_sprintf("unable to open '%s': %s", buf_ptr(file_path), err_str(err)));
return ira->codegen->builtin_types.entry_invalid;
}
}