File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -52,15 +52,10 @@ impl Decode<'_, Postgres> for BitVec {
52
52
let mut bytes = value. as_bytes ( ) ?;
53
53
let len = bytes. get_i32 ( ) ;
54
54
55
- if len < 0 {
56
- Err ( io:: Error :: new (
57
- io:: ErrorKind :: InvalidData ,
58
- "Negative VARBIT length." ,
59
- ) ) ?
60
- }
55
+ let len = usize:: try_from ( len) . map_err ( |_| format ! ( "invalid VARBIT len: {len}" ) ) ?;
61
56
62
57
// The smallest amount of data we can read is one byte
63
- let bytes_len = ( len as usize + 7 ) / 8 ;
58
+ let bytes_len = ( len + 7 ) / 8 ;
64
59
65
60
if bytes. remaining ( ) != bytes_len {
66
61
Err ( io:: Error :: new (
@@ -74,7 +69,7 @@ impl Decode<'_, Postgres> for BitVec {
74
69
// Chop off zeroes from the back. We get bits in bytes, so if
75
70
// our bitvec is not in full bytes, extra zeroes are added to
76
71
// the end.
77
- while bitvec. len ( ) > len as usize {
72
+ while bitvec. len ( ) > len {
78
73
bitvec. pop ( ) ;
79
74
}
80
75
You can’t perform that action at this time.
0 commit comments