From d66afa4586b3753182947d03d183a054d220e403 Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jeremy@system76.com> Date: Tue, 27 Nov 2018 20:54:37 -0700 Subject: [PATCH] Do not return mutable pointer from strsignal --- src/header/string/mod.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/header/string/mod.rs b/src/header/string/mod.rs index 0162e409f..1e1d018b3 100644 --- a/src/header/string/mod.rs +++ b/src/header/string/mod.rs @@ -355,10 +355,8 @@ pub unsafe extern "C" fn strrchr(s: *const c_char, c: c_int) -> *mut c_char { } #[no_mangle] -pub unsafe extern "C" fn strsignal(sig: c_int) -> *mut c_char { - // Mutating this is undefined behavior I believe. But I just can't create a - // &'static mut str. Alternative is allocating everything on the heap... - signal::_signal_strings[sig as usize].as_ptr() as *const c_char as *mut c_char +pub unsafe extern "C" fn strsignal(sig: c_int) -> *const c_char { + signal::_signal_strings[sig as usize].as_ptr() as *const c_char } #[no_mangle] -- GitLab