Skip to content

Commit 353812f

Browse files
committed
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
1 parent b46a1d3 commit 353812f

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/config.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,7 @@ impl NativeClientConfig {
150150
}
151151

152152
// Convert the C string to a Rust string.
153-
Ok(CStr::from_bytes_with_nul(&buf)
154-
.unwrap()
155-
.to_string_lossy()
156-
.into())
153+
Ok(String::from_utf8_lossy(&buf).to_string())
157154
}
158155
}
159156

0 commit comments

Comments
 (0)