Skip to content

Commit

Permalink
[audit] #8: _isContract optimization (#53)
Browse files Browse the repository at this point in the history
* Optimization

* Remove assembly, use
  • Loading branch information
stevieraykatz authored Jun 26, 2024
1 parent c02661e commit fbad20c
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/L2/ReverseRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ contract ReverseRegistrar is Ownable {
/// @return `true` if the address returned from `Ownable:owner()` == msg.sender, else `false`.
function _ownsContract(address addr) internal view returns (bool) {
// Determine if a contract exists at `addr` and return early if not
if (!_isContract(addr)) {
if (addr.code.length == 0) {
return false;
}
// If a contract does exist, try and call `Ownable.owner()`
Expand All @@ -193,17 +193,4 @@ contract ReverseRegistrar is Ownable {
return false;
}
}

/// @notice Check if the provided `addr` has a nonzero `extcodesize`.
///
/// @param addr The address to check.
///
/// @return `true` if `extcodesize` > 0, else `false`.
function _isContract(address addr) internal view returns (bool) {
uint32 size;
assembly {
size := extcodesize(addr)
}
return size > 0;
}
}

0 comments on commit fbad20c

Please sign in to comment.