# fillRectList(const juce::RectangleList\<float\> - Missing Range Check crash

**URL:** <https://forum.juce.com/t/fillrectlist-const-juce-rectanglelist-float-missing-range-check-crash/14537>\
**Category:** General JUCE discussion\
**Created:** [March 27, 2015, 12:44pm UTC](https://forum.juce.com/t/fillrectlist-const-juce-rectanglelist-float-missing-range-check-crash/14537 "2015-03-27T12:44:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [March 27, 2015, 12:44pm UTC](https://forum.juce.com/t/fillrectlist-const-juce-rectanglelist-float-missing-range-check-crash/14537/1 "2015-03-27T12:44:11Z")

</div>

not sure how i get to this result, but i think there should be a rangecheck, when the Rectangle-list&nbsp;contains silly values

addEdgePointPair, crashes if y is negative, shouldn't there be a range check

const Rectangle\<float\>\* r =&nbsp;

&nbsp;{pos={x=512.000000 y=-1330.39221 } w=1.00000000 h=1.59887695 }

First-chance exception at 0x556E85AB (my.dll) in Cubase7.exe: 0xC0000005: Access violation reading location 0x301CF8FC.

**&nbsp;&nbsp;&nbsp; &nbsp;juce::EdgeTable::addEdgePointPair(int x1=131072, int x2=131328, int y=-1331, int winding=99) Line 439&nbsp;&nbsp; &nbsp;C++  
\>&nbsp;&nbsp; &nbsp;juce::EdgeTable::EdgeTable(const juce::RectangleList\<float\> & rectanglesToAdd={...}) Line 179&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::RenderingHelpers::ClipRegions\<juce::RenderingHelpers::SoftwareRendererSavedState\>::EdgeTableRegion::EdgeTableRegion(const juce::RectangleList\<float\> & r={...}) Line 1588&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::RenderingHelpers::SavedStateBase\<juce::RenderingHelpers::SoftwareRendererSavedState\>::fillRectList(const juce::RectangleList\<float\> & list={...}) Line 2256&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::RenderingHelpers::StackBasedLowLevelGraphicsContext\<juce::RenderingHelpers::SoftwareRendererSavedState\>::fillRectList(const juce::RectangleList\<float\> & list={...}) Line 2661&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Graphics::fillRectList(const juce::RectangleList\<float\> & rectangles={...}) Line 364&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;SpectrumDisplayComponent::paint(juce::Graphics & g={...}) Line 160&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintComponentAndChildren(juce::Graphics & g={...}) Line 1964&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintEntireComponent(juce::Graphics & g={...}, bool ignoreAlphaLevel=false) Line 2069&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintWithinParentContext(juce::Graphics & g={...}) Line 1947&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintComponentAndChildren(juce::Graphics & g={...}) Line 2010&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintEntireComponent(juce::Graphics & g={...}, bool ignoreAlphaLevel=false) Line 2069&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintWithinParentContext(juce::Graphics & g={...}) Line 1947&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintComponentAndChildren(juce::Graphics & g={...}) Line 2010&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintEntireComponent(juce::Graphics & g={...}, bool ignoreAlphaLevel=false) Line 2069&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintWithinParentContext(juce::Graphics & g={...}) Line 1947&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintComponentAndChildren(juce::Graphics & g={...}) Line 2010&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintEntireComponent(juce::Graphics & g={...}, bool ignoreAlphaLevel=false) Line 2069&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintWithinParentContext(juce::Graphics & g={...}) Line 1947&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintComponentAndChildren(juce::Graphics & g={...}) Line 2010&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::Component::paintEntireComponent(juce::Graphics & g={...}, bool ignoreAlphaLevel=true) Line 2069&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::ComponentPeer::handlePaint(juce::LowLevelGraphicsContext & contextToPaintTo={...}) Line 160&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::HWNDComponentPeer::performPaint(HDC\_\_ \* dc=0x040124d6, HRGN\_\_ \* rgn=0x0f042504, int regionType=2, tagPAINTSTRUCT & paintStruct={...}) Line 1646&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::HWNDComponentPeer::handlePaintMessage() Line 1541&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::HWNDComponentPeer::peerWindowProc(HWND\_\_ \* h=0x00100402, unsigned int message=15, unsigned int wParam=0, long lParam=0) Line 2406&nbsp;&nbsp; &nbsp;C++  
&nbsp;&nbsp;&nbsp; &nbsp;juce::HWNDComponentPeer::windowProc(HWND\_\_ \* h=0x00100402, unsigned int message=15, unsigned int wParam=0, long lParam=0) Line 2358&nbsp;&nbsp; &nbsp;C++**

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 27, 2015, 12:52pm UTC](https://forum.juce.com/t/fillrectlist-const-juce-rectanglelist-float-missing-range-check-crash/14537/2 "2015-03-27T12:52:04Z")

</div>

Looks like an edge case somewhere is letting the negative Y value slip through - it shouldn't get as far as reaching the&nbsp;addEdgePointPair call. Do you have code that I could use to try to&nbsp;reproduce this?

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [March 27, 2015, 2:55pm UTC](https://forum.juce.com/t/fillrectlist-const-juce-rectanglelist-float-missing-range-check-crash/14537/3 "2015-03-27T14:55:43Z")

</div>

(forum upload seems not to work),&nbsp;

i think there the reason are&nbsp;#INF values in the rectangle-list&nbsp;which, which let "bounds" to be

bounds&nbsp;&nbsp; &nbsp;{pos={x=0 y=-2147483648 }

which result in the negativ y in&nbsp;&nbsp;addEdgePointPair

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;lastLine&nbsp;&nbsp; &nbsp;234&nbsp;&nbsp; &nbsp;const int  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;x1&nbsp;&nbsp; &nbsp;116992&nbsp;&nbsp; &nbsp;const int  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;y1&nbsp;&nbsp; &nbsp;-338480&nbsp;&nbsp; &nbsp;const int  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;x2&nbsp;&nbsp; &nbsp;117248&nbsp;&nbsp; &nbsp;const int  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;y2&nbsp;&nbsp; &nbsp;59904&nbsp;&nbsp; &nbsp;const int  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;y&nbsp;&nbsp; &nbsp;-1323&nbsp;&nbsp; &nbsp;int  
+&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;e&nbsp;&nbsp; &nbsp;0x30d4dae8 {pos={x=-4.22016832e+037 y=-1.21979282e-012 } w=-1.21979282e-012 h=-1.58839967e+038 }&nbsp;&nbsp; &nbsp;const juce::Rectangle\<float\> \* const  
+&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;r&nbsp;&nbsp; &nbsp;0x30d4d618 {pos={x=457.000000 y=-1322.18689 } w=1.00000000 h=1556.18689 }&nbsp;&nbsp; &nbsp;const juce::Rectangle\<float\> \*  
-&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;this&nbsp;&nbsp; &nbsp;0x30993120 {table={data=0x30e3de90 {0} } bounds={pos={x=0 y=-2147483648 } w=534 h=1 } maxEdgesPerLine=...}&nbsp;&nbsp; &nbsp;juce::EdgeTable \*  
+&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;table&nbsp;&nbsp; &nbsp;{data=0x30e3de90 {0} }&nbsp;&nbsp; &nbsp;juce::HeapBlock\<int,0\>  
-&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;bounds&nbsp;&nbsp; &nbsp;{pos={x=0 y=-2147483648 } w=534 h=1 }&nbsp;&nbsp; &nbsp;juce::Rectangle\<int\>  
+&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pos&nbsp;&nbsp; &nbsp;{x=0 y=-2147483648 }&nbsp;&nbsp; &nbsp;juce::Point\<int\>  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;w&nbsp;&nbsp; &nbsp;534&nbsp;&nbsp; &nbsp;int  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;h&nbsp;&nbsp; &nbsp;1&nbsp;&nbsp; &nbsp;int  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;maxEdgesPerLine&nbsp;&nbsp; &nbsp;1068&nbsp;&nbsp; &nbsp;int  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;lineStrideElements&nbsp;&nbsp; &nbsp;2137&nbsp;&nbsp; &nbsp;int  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;needToCheckEmptiness&nbsp;&nbsp; &nbsp;true&nbsp;&nbsp; &nbsp;bool  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;leakDetector216&nbsp;&nbsp; &nbsp;{...}&nbsp;&nbsp; &nbsp;juce::LeakedObjectDetector\<juce::EdgeTable\>  
-&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;rectanglesToAdd&nbsp;&nbsp; &nbsp;{rects={data={elements={data=0x30d4b988 {...} } numAllocated=534 } numUsed=534 } }&nbsp;&nbsp; &nbsp;const juce::RectangleList\<float\> &  
-&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;rects&nbsp;&nbsp; &nbsp;{data={elements={data=0x30d4b988 {pos={...} w=1.00000000 h=1.#INF0000 } } numAllocated=534 } numUsed=...}&nbsp;&nbsp; &nbsp;juce::Array\<juce::Rectangle\<float\>,juce::DummyCriticalSection,0\>  
-&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;data&nbsp;&nbsp; &nbsp;{elements={data=0x30d4b988 {pos={x=0.000000000 y=-1.#INF0000 } w=1.00000000 h=1.#INF0000 } } numAllocated=...}&nbsp;&nbsp; &nbsp;juce::ArrayAllocationBase\<juce::Rectangle\<float\>,juce::DummyCriticalSection\>  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;juce::DummyCriticalSection&nbsp;&nbsp; &nbsp;{...}&nbsp;&nbsp; &nbsp;juce::DummyCriticalSection  
-&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;elements&nbsp;&nbsp; &nbsp;{data=0x30d4b988 {pos={x=0.000000000 y=-1.#INF0000 } w=1.00000000 h=1.#INF0000 } }&nbsp;&nbsp; &nbsp;juce::HeapBlock\<juce::Rectangle\<float\>,0\>  
-&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;data&nbsp;&nbsp; &nbsp;0x30d4b988 {pos={x=0.000000000 y=-1.#INF0000 } w=1.00000000 h=1.#INF0000 }&nbsp;&nbsp; &nbsp;juce::Rectangle\<float\> \*  
-&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pos&nbsp;&nbsp; &nbsp;{x=0.000000000 y=-1.#INF0000 }&nbsp;&nbsp; &nbsp;juce::Point\<float\>  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;x&nbsp;&nbsp; &nbsp;0.000000000&nbsp;&nbsp; &nbsp;float  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;y&nbsp;&nbsp; &nbsp;-1.#INF0000&nbsp;&nbsp; &nbsp;float  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;w&nbsp;&nbsp; &nbsp;1.00000000&nbsp;&nbsp; &nbsp;float  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;h&nbsp;&nbsp; &nbsp;1.#INF0000&nbsp;&nbsp; &nbsp;float  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;numAllocated&nbsp;&nbsp; &nbsp;534&nbsp;&nbsp; &nbsp;int  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;numUsed&nbsp;&nbsp; &nbsp;534&nbsp;&nbsp; &nbsp;int

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [March 30, 2015, 11:23am UTC](https://forum.juce.com/t/fillrectlist-const-juce-rectanglelist-float-missing-range-check-crash/14537/4 "2015-03-30T11:23:54Z")

</div>

ok, but where did those values come from? I'd need to be able to reproduce this in order to work out where these values need to be caught.

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [March 30, 2015, 9:18pm UTC](https://forum.juce.com/t/fillrectlist-const-juce-rectanglelist-float-missing-range-check-crash/14537/5 "2015-03-30T21:18:05Z")

</div>

The&nbsp;#INF values in the Rectangle List, come from my spectrum analyzer, they are of cause wrong, but i think this should not result in a bad access, when i give any kind of floats to a UI routine.&nbsp;&nbsp;&nbsp;

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [March 31, 2015, 9:18am UTC](https://forum.juce.com/t/fillrectlist-const-juce-rectanglelist-float-missing-range-check-crash/14537/6 "2015-03-31T09:18:33Z")

</div>

This is why the assertion is there. If you run your code in debug mode you should be hitting the assertion first. This is to warn you that without fixing something needs fixing - in your case, it's the spectrum analyzer.

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [March 31, 2015, 11:01am UTC](https://forum.juce.com/t/fillrectlist-const-juce-rectanglelist-float-missing-range-check-crash/14537/7 "2015-03-31T11:01:00Z")

</div>

well i didn't run into any assertion.&nbsp;

IMHO, wherever i give &nbsp;a float value to user-infterface-subroutine (there can always&nbsp;be edge cases (for examples because of rounding erros)&nbsp;in release builds, where&nbsp;INFs or NANs are generated, and INF and NANs&nbsp;ARE valid Float-values) it should never result in "BAD ACCESS" exception which crashes an application.&nbsp;

If i give a wrong pointer, or wrong integer&nbsp;index or length, this would be ok, but giving a "wrong" float value to a UI-subroutine should not crash an application.

&nbsp;

&nbsp;

&nbsp;
