From 353812ff958b4b65f9e65dd22a60e770ed6ba948 Mon Sep 17 00:00:00 2001 From: Misha Padalka Date: Tue, 13 Jun 2023 17:08:38 +0300 Subject: [PATCH] Fix panic on getting config value from NativeConfig Kafka can return string with multiple \0 chars (seen on Windows x64), and CStr::from_bytes_with_nul panics in that case. String::from_utf8_lossy() handles that ok --- src/config.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index da4885a78..296d9f867 100644 --- a/src/config.rs +++ b/src/config.rs @@ -150,10 +150,7 @@ impl NativeClientConfig { } // Convert the C string to a Rust string. - Ok(CStr::from_bytes_with_nul(&buf) - .unwrap() - .to_string_lossy() - .into()) + Ok(String::from_utf8_lossy(&buf).to_string()) } }