Skip to content

Commit

Permalink
Fix panic on getting config value from NativeConfig
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Magister committed Jun 13, 2023
1 parent b46a1d3 commit 353812f
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

Expand Down

0 comments on commit 353812f

Please sign in to comment.