BR: Fill rects with huge co-ordinates crashes on Windows

Steps to reproduce:

  • Use latest develop code
  • Make a rect way off screen
  • Draw it
  • Crash

Code:

void MainComponent::paint (juce::Graphics& g)
{
    // (Our component is opaque, so we must completely fill the background with a solid colour)
    g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));

    g.setColour (juce::Colours::white);

    juce::Rectangle<int> r (0, -2147483648, 24, 2);
    g.fillRect (r);
}

https://github.com/FigBug/juce_bugs/tree/master/RectCrash

Expected behaviour:

  • Don’t draw anything
  • Don’t crash
1 Like

Draw rect seems to crash to.

g.drawRect (juce::Rectangle<int> (71, 235, 43989769, 104), 2);

release build, resize the window until it crashes

Trying to fill/draw a rect with a negative coordinate is not supported and there is an internal min/max for rectangles. It’s 1073741823 (0x3fffffff).

This will be caught with a jassert in debug mode.