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...@@ -18187,17 +18187,18 @@ static ZigType *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionE
18187 &source_dir_path,18187 &source_dir_path,
18188 rel_file_path,18188 rel_file_path,
18189 };18189 };
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
18192 // load from file system into const expr18193 // load from file system into const expr
18193 Buf *file_contents = buf_alloc();18194 Buf *file_contents = buf_alloc();
18194 int err;18195 int err;
18195 if ((err = file_fetch(ira->codegen, &file_path, file_contents))) {18196 if ((err = file_fetch(ira->codegen, file_path, file_contents))) {
18196 if (err == ErrorFileNotFound) {18197 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)));
18198 return ira->codegen->builtin_types.entry_invalid;18199 return ira->codegen->builtin_types.entry_invalid;
18199 } else {18200 } 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)));
18201 return ira->codegen->builtin_types.entry_invalid;18202 return ira->codegen->builtin_types.entry_invalid;
18202 }18203 }
18203 }18204 }