authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-18 10:25:37-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-18 10:25:57-04:00
log1fc2019031ef427e02acc88d7ce1c15372556c4d
tree452f5f81349b1858d3b3790038402784bac75310
parent93ff5024a4186d0067df969d403d311ac978996c
signaturelock-open Commit is signed but in an unrecognized format.

fix @embedFile reading garbage memory

closes #1547

1 files changed, 5 insertions(+), 4 deletions(-)

src/ir.cpp+5-4
......@@ -18187,17 +18187,18 @@ static ZigType *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionE
1818718187 &source_dir_path,
1818818188 rel_file_path,
1818918189 };
18190 Buf file_path = os_path_resolve(resolve_paths, 2);
18190 Buf *file_path = buf_alloc();
18191 *file_path = os_path_resolve(resolve_paths, 2);
1819118192
1819218193 // load from file system into const expr
1819318194 Buf *file_contents = buf_alloc();
1819418195 int err;
18195 if ((err = file_fetch(ira->codegen, &file_path, file_contents))) {
18196 if ((err = file_fetch(ira->codegen, file_path, file_contents))) {
1819618197 if (err == ErrorFileNotFound) {
18197 ir_add_error(ira, instruction->name, buf_sprintf("unable to find '%s'", buf_ptr(&file_path)));
18198 ir_add_error(ira, instruction->name, buf_sprintf("unable to find '%s'", buf_ptr(file_path)));
1819818199 return ira->codegen->builtin_types.entry_invalid;
1819918200 } else {
18200 ir_add_error(ira, instruction->name, buf_sprintf("unable to open '%s': %s", buf_ptr(&file_path), err_str(err)));
18201 ir_add_error(ira, instruction->name, buf_sprintf("unable to open '%s': %s", buf_ptr(file_path), err_str(err)));
1820118202 return ira->codegen->builtin_types.entry_invalid;
1820218203 }
1820318204 }