raysan5 / raygui

A simple and easy-to-use immediate-mode gui library
zlib License
3.26k stars 280 forks source link

Fix division by zero in GuiScrollBar function #396

Closed Elkantor closed 3 months ago

Elkantor commented 3 months ago

When trying to use the floating window example, I got several times some crashes when expanding the window size. It's caused in the GuiScrollBar function, when the maxValue is equal to the minValue (I don't know if this case is intended in the first place). Because valueRange variable is maxValue minus minValue, then it is equal to 0, and triggers a crash later, when we use it in division (division by 0).

I'm not sure if it's the best fix, maybe minValue == maxValue is not indentend in the first place and we should fix this problem earlier?

raysan5 commented 3 months ago

@Elkantor thanks for the review.

I'm not sure if it's the best fix, maybe minValue == maxValue is not indentend in the first place and we should fix this problem earlier?

Fix looks ok to me, avoiding the crash is the priority.