File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -482,12 +482,8 @@ pub(crate) fn write_label(
482
482
/// is longer than 255 bytes. (The size restriction exists so that searching
483
483
/// for a label during deserialization can be done in small bounded space.)
484
484
pub ( crate ) fn write_label_len ( label : & str ) -> usize {
485
- if label. len ( ) > 255 {
486
- panic ! ( "label must not be longer than 255 bytes" ) ;
487
- }
488
- if label. as_bytes ( ) . iter ( ) . position ( |& b| b == 0 ) . is_some ( ) {
489
- panic ! ( "label must not contain NUL bytes" ) ;
490
- }
485
+ assert ! ( label. len( ) <= 255 , "label must not be longer than 255 bytes" ) ;
486
+ assert ! ( label. bytes( ) . all( |b| b != 0 ) , "label must not contain NUL bytes" ) ;
491
487
let label_len = label. len ( ) + 1 ; // +1 for the NUL terminator
492
488
label_len + padding_len ( label_len)
493
489
}
You can’t perform that action at this time.
0 commit comments