Avoid panic by unitialized string of strlen

Wildan M 036dd3fb 5f8fb9c0

Changed files
+3 -1
src
header
string
+3 -1
src/header/string/mod.rs
··· 423 /// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/strlen.html>. 424 #[unsafe(no_mangle)] 425 pub unsafe extern "C" fn strlen(s: *const c_char) -> size_t { 426 - unsafe { NulTerminated::new(s).unwrap() }.count() 427 } 428 429 /// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/strncat.html>.
··· 423 /// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/strlen.html>. 424 #[unsafe(no_mangle)] 425 pub unsafe extern "C" fn strlen(s: *const c_char) -> size_t { 426 + unsafe { NulTerminated::new(s) } 427 + .map(|s| s.count()) 428 + .unwrap_or(0) 429 } 430 431 /// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/strncat.html>.