Fix division by zero during modulo operation
This commit is contained in:
parent
2c2fd8f3f9
commit
7417b58bad
4
tree.go
4
tree.go
@ -333,10 +333,14 @@ func (operation *Operation) Solution () (solution int64, err error) {
|
|||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
if index == 0 {
|
if index == 0 {
|
||||||
solution = subSolution
|
solution = subSolution
|
||||||
|
} else {
|
||||||
|
if subSolution == 0 {
|
||||||
|
err = ErrorDivideByZero
|
||||||
} else {
|
} else {
|
||||||
solution %= subSolution
|
solution %= subSolution
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case OpcodeOr:
|
case OpcodeOr:
|
||||||
for _, operand := range operation.operands {
|
for _, operand := range operation.operands {
|
||||||
subSolution, err = operand.Solution()
|
subSolution, err = operand.Solution()
|
||||||
|
Loading…
Reference in New Issue
Block a user