Skip to content

Commit 257bd7c

Browse files
committed
fix the bug: contract A create contract B, after A suicide, when call B's function, null pointer.
1 parent 73d7536 commit 257bd7c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/main/java/org/tron/common/runtime/RuntimeImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ public long getTotalEnergyLimitWithFixRatio(AccountCapsule creator, AccountCapsu
315315
public long getTotalEnergyLimit(AccountCapsule creator, AccountCapsule caller,
316316
TriggerSmartContract contract, long feeLimit, long callValue)
317317
throws ContractValidateException {
318+
if (VMConfig.allowTvmConstantinople()) {
319+
if (Objects.isNull(creator)) {
320+
return getAccountEnergyLimitWithFixRatio(caller, feeLimit, callValue);
321+
}
322+
}
318323
// according to version
319324
if (VMConfig.getEnergyLimitHardFork()) {
320325
return getTotalEnergyLimitWithFixRatio(creator, caller, contract, feeLimit, callValue);

src/main/java/org/tron/core/capsule/ReceiptCapsule.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.tron.core.capsule;
22

3+
import java.util.Objects;
34
import lombok.Getter;
45
import lombok.Setter;
56
import org.tron.common.runtime.config.VMConfig;
@@ -105,6 +106,13 @@ public void payEnergyBill(Manager manager, AccountCapsule origin, AccountCapsule
105106
return;
106107
}
107108

109+
if (VMConfig.allowTvmConstantinople()) {
110+
if (Objects.isNull(origin)) {
111+
payEnergyBill(manager, caller, receipt.getEnergyUsageTotal(), energyProcessor, now);
112+
return;
113+
}
114+
}
115+
108116
if (caller.getAddress().equals(origin.getAddress())) {
109117
payEnergyBill(manager, caller, receipt.getEnergyUsageTotal(), energyProcessor, now);
110118
} else {

0 commit comments

Comments
 (0)