goostengine / goost

A general-purpose, extensible and customizable C++ extension for Godot Engine.
https://goostengine.github.io/
MIT License
481 stars 18 forks source link

`Random.choices()` division by zero #179

Closed Xrayez closed 2 years ago

Xrayez commented 2 years ago

Goost and Godot version: 4cfacd390a0e2f3c832f19677edbb195a234971f, 3.x

Steps to reproduce: This is input from the fuzzer: https://github.com/goostengine/goost-fuzzer/runs/5261841226

/home/runner/work/goost-fuzzer/goost-fuzzer/goost/core/math/random.cpp:136:32: runtime error: division by zero
Random.choices({"roman" : 22, 22 : 25, BoxShape.new() : BoxShape.new()}, 37, PoolIntArray([]), true)

CC @sumadithya

rusty-tendrils commented 2 years ago

I just didn't have checks for when is_cumulative is true .

Do I have to make a new branch for this issue (to make a PR)?

Xrayez commented 2 years ago

Do I have to make a new branch for this issue (to make a PR)?

Yeah, feel free to submit a new PR referencing this issue (like "Closes #179", to automatically close it upon fixing).

You can fix this as part of adding documentation/tests. This is an opportunity to write unit tests in fact, to verify it works as expected.