prometheus-lua / Prometheus

Lua Obfuscator written in pure Lua
https://levno-710.gitbook.io/prometheus/
GNU Affero General Public License v3.0
205 stars 61 forks source link

[BUG] DivExpression problem on division by 0 #65

Closed britzl closed 2 years ago

britzl commented 2 years ago

Describe the bug The DivExpression in ast.lua has a simplify argument which will perform the division and store the result if both left and right-hand side of the expression is a constant. This works great in all cases except when dividing by 0.

print(1/0) -- inf
print(-1/0) -- -inf
print(0/0) -- nan

The above three expressions return constants inf and nan of type number. The problem when simplifying this is that the resulting string will become:

print(inf) -- nil
print(-inf) -- attempt to perform arithmetic on global 'inf' (a nil value)
print(nan) -- nil

Expected behavior The DivExpression should not simplify the expression when the right hand side is 0.

To Reproduce Steps to reproduce the behavior:

Observe divexpression.obfuscated.lua