Skip to content

Commit

Permalink
Add check for empty vector during event emission (#8448)
Browse files Browse the repository at this point in the history
  • Loading branch information
alnoki committed May 31, 2023
1 parent c522f80 commit 3fe9436
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions aptos-move/framework/aptos-framework/doc/multisig_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -1641,8 +1641,9 @@ maliciously alter the owners list.
<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_length">vector::length</a>(owners) &gt;= multisig_account_resource.num_signatures_required,
<a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_state">error::invalid_state</a>(<a href="multisig_account.md#0x1_multisig_account_ENOT_ENOUGH_OWNERS">ENOT_ENOUGH_OWNERS</a>),
);

emit_event(&<b>mut</b> multisig_account_resource.remove_owners_events, <a href="multisig_account.md#0x1_multisig_account_RemoveOwnersEvent">RemoveOwnersEvent</a> { owners_removed });
<b>if</b> (<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_length">vector::length</a>(&owners_removed) &gt; 0) {
emit_event(&<b>mut</b> multisig_account_resource.remove_owners_events, <a href="multisig_account.md#0x1_multisig_account_RemoveOwnersEvent">RemoveOwnersEvent</a> { owners_removed });
}
}
</code></pre>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,9 @@ module aptos_framework::multisig_account {
vector::length(owners) >= multisig_account_resource.num_signatures_required,
error::invalid_state(ENOT_ENOUGH_OWNERS),
);

emit_event(&mut multisig_account_resource.remove_owners_events, RemoveOwnersEvent { owners_removed });
if (vector::length(&owners_removed) > 0) {
emit_event(&mut multisig_account_resource.remove_owners_events, RemoveOwnersEvent { owners_removed });
}
}

/// Update the number of signatures required then remove owners, in a single operation.
Expand Down

0 comments on commit 3fe9436

Please sign in to comment.