Skip to content

Commit

Permalink
Fix nil pointer dereference on gas estimation (ethereum#133)
Browse files Browse the repository at this point in the history
* fix(contracts): remove double variable declaration

* fix(contracts): remove unneeded change
  • Loading branch information
tremblaythibaultl authored Jun 30, 2023
1 parent b04fd5b commit 12e6610
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -1465,9 +1465,9 @@ func (e *fheAdd) RequiredGas(accessibleState PrecompileAccessibleState, input []
logger.Error("fheAdd/Sub RequiredGas() can not detect if operator is meant to be scalar", "err", err, "input", hex.EncodeToString(input))
return 0
}
var lhs *verifiedCiphertext
var lhs, rhs *verifiedCiphertext
if !isScalar {
lhs, rhs, err := get2VerifiedOperands(accessibleState, input)
lhs, rhs, err = get2VerifiedOperands(accessibleState, input)
if err != nil {
logger.Error("fheAdd/Sub RequiredGas() ciphertext inputs not verified", "err", err, "input", hex.EncodeToString(input))
return 0
Expand Down Expand Up @@ -1933,9 +1933,9 @@ func (e *fheLe) RequiredGas(accessibleState PrecompileAccessibleState, input []b
logger.Error("comparison RequiredGas() can not detect if operator is meant to be scalar", "err", err, "input", hex.EncodeToString(input))
return 0
}
var lhs *verifiedCiphertext
var lhs, rhs *verifiedCiphertext
if !isScalar {
lhs, rhs, err := get2VerifiedOperands(accessibleState, input)
lhs, rhs, err = get2VerifiedOperands(accessibleState, input)
if err != nil {
logger.Error("comparison RequiredGas() ciphertext inputs not verified", "err", err, "input", hex.EncodeToString(input))
return 0
Expand Down Expand Up @@ -2123,9 +2123,9 @@ func (e *fheMul) RequiredGas(accessibleState PrecompileAccessibleState, input []
logger.Error("fheMul RequiredGas() can not detect if operator is meant to be scalar", "err", err, "input", hex.EncodeToString(input))
return 0
}
var lhs *verifiedCiphertext
var lhs, rhs *verifiedCiphertext
if !isScalar {
lhs, rhs, err := get2VerifiedOperands(accessibleState, input)
lhs, rhs, err = get2VerifiedOperands(accessibleState, input)
if err != nil {
logger.Error("fheMul RequiredGas() ciphertext inputs not verified", "err", err, "input", hex.EncodeToString(input))
return 0
Expand Down Expand Up @@ -2427,9 +2427,9 @@ func (e *fheShl) RequiredGas(accessibleState PrecompileAccessibleState, input []
logger.Error("fheShift RequiredGas() can not detect if operator is meant to be scalar", "err", err, "input", hex.EncodeToString(input))
return 0
}
var lhs *verifiedCiphertext
var lhs, rhs *verifiedCiphertext
if !isScalar {
lhs, rhs, err := get2VerifiedOperands(accessibleState, input)
lhs, rhs, err = get2VerifiedOperands(accessibleState, input)
if err != nil {
logger.Error("fheShift RequiredGas() ciphertext inputs not verified", "err", err, "input", hex.EncodeToString(input))
return 0
Expand Down Expand Up @@ -3037,9 +3037,9 @@ func (e *fheMin) RequiredGas(accessibleState PrecompileAccessibleState, input []
logger.Error("fheMin/Max RequiredGas() can not detect if operator is meant to be scalar", "err", err, "input", hex.EncodeToString(input))
return 0
}
var lhs *verifiedCiphertext
var lhs, rhs *verifiedCiphertext
if !isScalar {
lhs, rhs, err := get2VerifiedOperands(accessibleState, input)
lhs, rhs, err = get2VerifiedOperands(accessibleState, input)
if err != nil {
logger.Error("fheMin/Max RequiredGas() ciphertext inputs not verified", "err", err, "input", hex.EncodeToString(input))
return 0
Expand Down

0 comments on commit 12e6610

Please sign in to comment.