1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

MessageBox: Avoid potential divide-by-zero for boxes with no buttons

This commit is contained in:
reuk 2024-10-16 16:06:59 +01:00
parent b292ba215a
commit 44a84e3a4d
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -66,7 +66,13 @@ std::unique_ptr<ScopedMessageBoxInterface> ScopedMessageBoxInterface::create (co
} }
private: private:
static int map (int button, int numButtons) { return (button + numButtons - 1) % numButtons; } static int map (int button, int numButtons)
{
if (numButtons <= 0)
return 0;
return (button + numButtons - 1) % numButtons;
}
std::unique_ptr<ScopedMessageBoxInterface> inner; std::unique_ptr<ScopedMessageBoxInterface> inner;
int numButtons = 0; int numButtons = 0;