Skip to content

Commit

Permalink
Remove unsafe usages (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
conorbros authored Sep 7, 2021
1 parent c889191 commit d5cc4b6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 87 deletions.
127 changes: 42 additions & 85 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion shotover-proxy/src/protocols/redis_codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ impl RedisCodec {
} else {
Message::new_query(
QueryMessage {
query_string: unsafe { String::from_utf8_unchecked(bulkstring.to_vec()) },
query_string: String::from_utf8_lossy(bulkstring.as_ref()).to_string(),
namespace: vec![],
primary_key: Default::default(),
query_values: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn wrap_command(qm: &QueryMessage) -> Result<Value> {
.iter()
.map(|v| {
if let Value::Bytes(b) = v {
unsafe { format!("'{}'", String::from_utf8_unchecked(b.to_vec())) }
format!("'{}'", String::from_utf8_lossy(b.as_ref()))
} else {
// TODO this might not be right... but we should only be dealing with bytes
format!("{:?}", v)
Expand Down

0 comments on commit d5cc4b6

Please sign in to comment.