From 5f5a7ce35f167743e6afe515d7c2ed8eac3a9c42 Mon Sep 17 00:00:00 2001 From: Ravi Tokas <110528769+devmev10@users.noreply.github.com> Date: Sun, 16 Jun 2024 15:27:36 +0530 Subject: [PATCH] Check for Zero Address Added a require statement in the changeOwner function to ensure that the new owner is not set to the zero address. This prevents accidental loss of control over the contract. --- .../src/templates/remixDefault/contracts/2_Owner.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/remix-ws-templates/src/templates/remixDefault/contracts/2_Owner.sol b/libs/remix-ws-templates/src/templates/remixDefault/contracts/2_Owner.sol index 9949f8cdd6..7aff9aa3d5 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/contracts/2_Owner.sol +++ b/libs/remix-ws-templates/src/templates/remixDefault/contracts/2_Owner.sol @@ -40,6 +40,7 @@ contract Owner { * @param newOwner address of new owner */ function changeOwner(address newOwner) public isOwner { + require(newOwner != address(0), "New owner should not be the zero address"); emit OwnerSet(owner, newOwner); owner = newOwner; } @@ -51,4 +52,4 @@ contract Owner { function getOwner() external view returns (address) { return owner; } -} \ No newline at end of file +}