From 1999f0daad505f414f97845ecde0a56b3c2fedfd Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 13 Apr 2018 11:10:17 -0400 Subject: 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. --- src/codegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 2aca143524..a58832f983 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -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: -- cgit v1.2.3