This repository was archived by the owner on Mar 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
token/program-2022/src/extension Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ fn get_extension_types(tlv_data: &[u8]) -> Result<Vec<ExtensionType>, ProgramErr
115
115
let mut start_index = 0 ;
116
116
while start_index < tlv_data. len ( ) {
117
117
let tlv_indices = get_tlv_indices ( start_index) ;
118
- if tlv_data. len ( ) <= tlv_indices. value_start {
118
+ if tlv_data. len ( ) < tlv_indices. value_start {
119
119
return Ok ( extension_types) ;
120
120
}
121
121
let extension_type =
@@ -1531,4 +1531,26 @@ mod test {
1531
1531
None
1532
1532
) ;
1533
1533
}
1534
+
1535
+ #[ test]
1536
+ fn test_extension_with_no_data ( ) {
1537
+ let account_size =
1538
+ ExtensionType :: get_account_len :: < Account > ( & [ ExtensionType :: ImmutableOwner ] ) ;
1539
+ let mut buffer = vec ! [ 0 ; account_size] ;
1540
+ let mut state =
1541
+ StateWithExtensionsMut :: < Account > :: unpack_uninitialized ( & mut buffer) . unwrap ( ) ;
1542
+ state. base = TEST_ACCOUNT ;
1543
+ state. pack_base ( ) ;
1544
+ state. init_account_type ( ) . unwrap ( ) ;
1545
+ state. init_extension :: < ImmutableOwner > ( ) . unwrap ( ) ;
1546
+
1547
+ assert_eq ! (
1548
+ get_first_extension_type( state. tlv_data) . unwrap( ) ,
1549
+ Some ( ExtensionType :: ImmutableOwner )
1550
+ ) ;
1551
+ assert_eq ! (
1552
+ get_extension_types( state. tlv_data) . unwrap( ) ,
1553
+ vec![ ExtensionType :: ImmutableOwner ]
1554
+ ) ;
1555
+ }
1534
1556
}
You can’t perform that action at this time.
0 commit comments