fix undefined behavior triggered by fn inline test

LLVM destroys the string that we use to test if LLVM deleted the
inlined function.

Also fixed forgetting to initialize a buffer in std lib path detection.
master
Andrew Kelley 2018-04-13 11:10:17 -04:00
parent 0f652b4d80
commit 1999f0daad
2 changed files with 2 additions and 1 deletions

View File

@ -467,7 +467,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
fn_table_entry->llvm_value, buf_ptr(&fn_export->name));
}
}
fn_table_entry->llvm_name = LLVMGetValueName(fn_table_entry->llvm_value);
fn_table_entry->llvm_name = strdup(LLVMGetValueName(fn_table_entry->llvm_value));
switch (fn_table_entry->fn_inline) {
case FnInlineAlways:

View File

@ -179,6 +179,7 @@ static int find_zig_lib_dir(Buf *out_path) {
Buf self_exe_path = BUF_INIT;
if (!(err = os_self_exe_path(&self_exe_path))) {
Buf *cur_path = &self_exe_path;
buf_resize(cur_path, 0);
for (;;) {
Buf *test_dir = buf_alloc();