@@ -26,6 +26,8 @@ pub struct ModuleTag {
2626impl ModuleTag {
2727 #[ cfg( feature = "builder" ) ]
2828 pub fn new ( start : u32 , end : u32 , cmdline : & str ) -> BoxedDst < Self > {
29+ assert ! ( end > start, "must have a size" ) ;
30+
2931 let mut cmdline_bytes: Vec < _ > = cmdline. bytes ( ) . collect ( ) ;
3032 if !cmdline_bytes. ends_with ( & [ 0 ] ) {
3133 // terminating null-byte
@@ -135,7 +137,7 @@ mod tests {
135137 & ( ( TagType :: Module . val ( ) ) . to_le_bytes ( ) ) ,
136138 & size. to_le_bytes ( ) ,
137139 & 0_u32 . to_le_bytes ( ) ,
138- & 0_u32 . to_le_bytes ( ) ,
140+ & 1_u32 . to_le_bytes ( ) ,
139141 MSG . as_bytes ( ) ,
140142 // Null Byte
141143 & [ 0 ] ,
@@ -161,15 +163,15 @@ mod tests {
161163 #[ test]
162164 #[ cfg( feature = "builder" ) ]
163165 fn test_build_str ( ) {
164- let tag = ModuleTag :: new ( 0 , 0 , MSG ) ;
166+ let tag = ModuleTag :: new ( 0 , 1 , MSG ) ;
165167 let bytes = tag. as_bytes ( ) ;
166168 assert_eq ! ( bytes, get_bytes( ) ) ;
167169 assert_eq ! ( tag. cmdline( ) , Ok ( MSG ) ) ;
168170
169171 // test also some bigger message
170- let tag = ModuleTag :: new ( 0 , 0 , "AbCdEfGhUjK YEAH" ) ;
172+ let tag = ModuleTag :: new ( 0 , 1 , "AbCdEfGhUjK YEAH" ) ;
171173 assert_eq ! ( tag. cmdline( ) , Ok ( "AbCdEfGhUjK YEAH" ) ) ;
172- let tag = ModuleTag :: new ( 0 , 0 , "AbCdEfGhUjK YEAH" . repeat ( 42 ) . as_str ( ) ) ;
174+ let tag = ModuleTag :: new ( 0 , 1 , "AbCdEfGhUjK YEAH" . repeat ( 42 ) . as_str ( ) ) ;
173175 assert_eq ! ( tag. cmdline( ) , Ok ( "AbCdEfGhUjK YEAH" . repeat( 42 ) . as_str( ) ) ) ;
174176 }
175177}
0 commit comments