rpc: fix possible panics in optimize_filters (#29146)

This commit is contained in:
Kirill Fomichev 2022-12-15 17:04:41 -03:00 committed by GitHub
parent 1e0a0e0ced
commit ccd96e246b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -2225,10 +2225,14 @@ fn optimize_filters(filters: &mut [RpcFilterType]) {
match &compare.bytes {
#[allow(deprecated)]
Binary(bytes) | Base58(bytes) => {
compare.bytes = Bytes(bs58::decode(bytes).into_vec().unwrap());
if let Ok(bytes) = bs58::decode(bytes).into_vec() {
compare.bytes = Bytes(bytes);
}
}
Base64(bytes) => {
compare.bytes = Bytes(base64::decode(bytes).unwrap());
if let Ok(bytes) = base64::decode(bytes) {
compare.bytes = Bytes(bytes);
}
}
_ => {}
}