When preparing event data in assembly, best practice is to write the event’s data payload into the free memory pointer region (mload(0x40)) and avoid touching the scratch space (0x00–0x3F). This keeps memory hygiene intact, prevents clobbering temporary workspace used by the compiler/runtime, and aligns with patterns already present in other functions (e.g., _allowance function computes with a ptr from 0x40).
In _approve, the code uses the memory-safe annotation but still writes to scratch space via mstore(0x00, value) right before emitting the Approval event with log3. This contradicts the intent of “memory-safe” and can introduce subtle fragility or maintenance hazards. The event payload should be written at ptr (the free memory pointer) instead.
Likelihood: High
_approve is executed frequently across wallets, DEXes, and protocols. The scratch-space write happens on every successful approval.
The contract uses inline assembly in multiple places; future refactors may introduce helpers that assume the scratch space isn’t clobbered right before/after event emissions.
Impact: Low
Memory hygiene violation / fragility: Clobbering 0x00 can interfere with temporary values expected by adjacent assembly or compiler-generated helpers, creating hard-to-debug behavior.
Inconsistency: Other functions in the codebase (e.g., _allowance) correctly use a ptr from mload(0x40); _approve should follow the same pattern to maintain consistency and safety.
It is recommended to use the free memory pointer (ptr := mload(0x40)) for the event data buffer and emit the log from ptr.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.
The contest is complete and the rewards are being distributed.