From a30654c16a34135fe0bd89984c3d3dc6605fa317 Mon Sep 17 00:00:00 2001 From: Jayden Windle Date: Tue, 27 Jun 2023 10:37:10 -0700 Subject: [PATCH] Added zero check to account proxy constructor --- src/AccountProxy.sol | 4 ++++ test/Account.t.sol | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/AccountProxy.sol b/src/AccountProxy.sol index 1acdad8..0c0d307 100644 --- a/src/AccountProxy.sol +++ b/src/AccountProxy.sol @@ -4,10 +4,14 @@ pragma solidity ^0.8.13; import "openzeppelin-contracts/proxy/ERC1967/ERC1967Upgrade.sol"; import "openzeppelin-contracts/proxy/Proxy.sol"; +error InvalidImplementation(); + contract AccountProxy is Proxy, ERC1967Upgrade { address immutable defaultImplementation; constructor(address _defaultImplementation) { + if (_defaultImplementation == address(0)) + revert InvalidImplementation(); defaultImplementation = _defaultImplementation; } diff --git a/test/Account.t.sol b/test/Account.t.sol index 3e30245..e419653 100644 --- a/test/Account.t.sol +++ b/test/Account.t.sol @@ -562,4 +562,9 @@ contract AccountTest is Test { assertEq(returnValue, 12345); } + + function testProxyZeroAddressInit() public { + vm.expectRevert(InvalidImplementation.selector); + new AccountProxy(address(0)); + } }