Crash in grid (with fix)

I found a bit of an edge-case crash in juce::Grid. It’s well-defined to use negative start or end row/column numbers for grid items - it starts counting from the last grid track, so it’s a useful way to align things to the right or bottom. But I found that if the negative number exceeds the actual number of tracks, we first hit the assertion at Grid.cpp:410 with a grid column < 1 then crashed.

The below diff fixes the crash and adds a test. I think that if we were following the grid specs exactly, doing this would add ‘implicit’ grid tracks before the start, and the code does appear to do that when you specify an end greater than the actual number of tracks. But I didn’t have time to add that feature and thread it through the code, so I just fixed the crash.

grid_fix.diff (1.8 KB)

1 Like

Thanks for reporting and for the suggested patch. I’ll try to get that fixed.

2 Likes

Thanks again, that’s fixed here:

Please let us know if you run into any new issues with this change.