authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-04-13 11:10:17-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-04-13 11:10:17-04:00
log1999f0daad505f414f97845ecde0a56b3c2fedfd
tree185598cde3a3f8b2320484e262899db5bc85b09e
parent0f652b4d80a57f5b5a1054d06cd5767ce52402a1

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.

2 files changed, 2 insertions(+), 1 deletions(-)

src/codegen.cpp+1-1
...@@ -467,7 +467,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {...@@ -467,7 +467,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
467 fn_table_entry->llvm_value, buf_ptr(&fn_export->name));467 fn_table_entry->llvm_value, buf_ptr(&fn_export->name));
468 }468 }
469 }469 }
470 fn_table_entry->llvm_name = LLVMGetValueName(fn_table_entry->llvm_value);470 fn_table_entry->llvm_name = strdup(LLVMGetValueName(fn_table_entry->llvm_value));
471471
472 switch (fn_table_entry->fn_inline) {472 switch (fn_table_entry->fn_inline) {
473 case FnInlineAlways:473 case FnInlineAlways:
src/main.cpp+1
...@@ -179,6 +179,7 @@ static int find_zig_lib_dir(Buf *out_path) {...@@ -179,6 +179,7 @@ static int find_zig_lib_dir(Buf *out_path) {
179 Buf self_exe_path = BUF_INIT;179 Buf self_exe_path = BUF_INIT;
180 if (!(err = os_self_exe_path(&self_exe_path))) {180 if (!(err = os_self_exe_path(&self_exe_path))) {
181 Buf *cur_path = &self_exe_path;181 Buf *cur_path = &self_exe_path;
182 buf_resize(cur_path, 0);
182183
183 for (;;) {184 for (;;) {
184 Buf *test_dir = buf_alloc();185 Buf *test_dir = buf_alloc();