Skip to content

Commit cc8f416

Browse files
committed
add parameter check in addressValid
1 parent 5ce5e26 commit cc8f416

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/main/java/org/tron/core/Wallet.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ public static boolean addressValid(ByteString bsAddress) {
131131
}
132132

133133
public static boolean addressValid(byte[] address) {
134+
if (address == null || address.length == 0) {
135+
logger.warn("Warning: Address is empty !!");
136+
return false;
137+
}
134138
if (address.length != Constant.ADDRESS_SIZE / 2) {
135139
logger.warn(
136140
"Warning: Address length need " + Constant.ADDRESS_SIZE + " but " + address.length
@@ -147,6 +151,10 @@ public static boolean addressValid(byte[] address) {
147151
}
148152

149153
public static boolean addressValid(String addressStr) {
154+
if (addressStr == null || "".equals(addressStr)) {
155+
logger.warn("Warning: Address is empty !!");
156+
return false;
157+
}
150158
try {
151159
byte[] address = ByteArray.fromHexString(addressStr);
152160
return addressValid(address);

0 commit comments

Comments
 (0)