From 6f92951a158947010d8353a3ce05112b00a97631 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 21 Mar 2025 10:01:26 +0000 Subject: [PATCH] Avoid sending a non-null pointer for empty strings --- compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 2eaaf127e41ea..35b34663a4714 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -643,10 +643,10 @@ fn create_file<'ll>( builder, file_name.as_c_char_ptr(), file_name.len(), - directory.as_c_char_ptr(), + if directory.is_empty() { ptr::null() } else { directory.as_c_char_ptr() }, directory.len(), hash_kind, - hash_value.as_c_char_ptr(), + if hash_value.is_empty() { ptr::null() } else { hash_value.as_c_char_ptr() }, hash_value.len(), source.map_or(ptr::null(), |x| x.as_c_char_ptr()), source.map_or(0, |x| x.len()),