Skip to content
medium Input Validation No SWC entry CWE-20

Array Length Mismatch in Batch Operations

SAFE-0074 Input Validation Checked automatically by the scanner
1

What goes wrong

Batch functions take parallel arrays (recipients[], amounts[]) without checking equal length, causing out-of-bounds reverts or, worse, silent misalignment of values.

2

How to fix it

the pattern that is safe
function airdrop(address[] calldata to, uint[] calldata amt) external {
    require(to.length == amt.length, "length");
    for (uint i; i<to.length; i++) token.safeTransfer(to[i], amt[i]);
}
Always validate parallel array lengths.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0074 among them. Paste an address or the source itself — a small per-scan fee, shown before you sign, or unlimited on any plan.

Run the scanner See how it is attacked Read the docs