File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
substrate/frame/system/src Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1+ title: 'frame-system: Don''t underflow the sufficients'
2+ doc:
3+ - audience: Node Dev
4+ description: |
5+ Fixes a potential underflow for `dec_sufficients`.
6+ crates:
7+ - name: frame-system
8+ bump: patch
Original file line number Diff line number Diff line change @@ -1693,7 +1693,7 @@ impl<T: Config> Pallet<T> {
16931693 DecRefStatus :: Reaped
16941694 } ,
16951695 ( x, _) => {
1696- account. sufficients = x - 1 ;
1696+ account. sufficients = x. saturating_sub ( 1 ) ;
16971697 * maybe_account = Some ( account) ;
16981698 DecRefStatus :: Exists
16991699 } ,
Original file line number Diff line number Diff line change @@ -155,6 +155,14 @@ fn provider_ref_handover_to_self_sufficient_ref_works() {
155155 } ) ;
156156}
157157
158+ #[ test]
159+ fn dec_sufficients_does_not_undeflow ( ) {
160+ new_test_ext ( ) . execute_with ( || {
161+ assert_eq ! ( System :: inc_providers( & 0 ) , IncRefStatus :: Created ) ;
162+ assert_eq ! ( System :: dec_sufficients( & 0 ) , DecRefStatus :: Exists ) ;
163+ } ) ;
164+ }
165+
158166#[ test]
159167fn self_sufficient_ref_handover_to_provider_ref_works ( ) {
160168 new_test_ext ( ) . execute_with ( || {
You can’t perform that action at this time.
0 commit comments