title: Nested cfloops with less records than outer loop cause "array index out of range" error
body: <p>I'm very curious why this is happening. I've run into it twice now, and after a ton of googling/so'ing, I haven't found any reason I actually understand. The gist of it:</p>
  
  <p>Query 1: selectContent (6 records; no blanks/nulls etc)</p>
  
  <p>Query 2: selectPricing (5 records; no blanks/nulls etc)</p>
  
  <p>Output: </p>
  
  <pre><code>&lt;cfloop query="selectContent"&gt;
      &lt;section&gt;
          #selectContent.h2#
          &lt;cfif selectContent.id eq 3&gt;
              &lt;cfloop query="selectPricing" group="groupCol"&gt;
                  &lt;table class="pricing"&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;th&gt;#description#&lt;/th&gt;
                          &lt;th&gt;Price&lt;/th&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;
                      &lt;cfloop&gt;
                      &lt;tr&gt;
                          &lt;td&gt;#selectPricing.description#&lt;/td&gt;
                          &lt;td&gt;#selectPricing.price#&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;/cfloop&gt;
                  &lt;/tbody&gt;
                  &lt;/table&gt;
              &lt;/cfloop&gt;
          &lt;/cfif&gt;
          #selectContent.content#
      &lt;/section&gt;
  &lt;/cfloop&gt;
  </code></pre>
  
  <p>This will give the following error: <em>Array index out of range: 5</em></p>
  
  <p>The error only occurs when the second query has less records than the first. Essentially it feels like that first cfloop takes over the loop iteration from that second one and this causes the issue, but also only if you have that third grouped cfloop in there. The entire inner cfloop runs, as  is there in the source.</p>
  
  <p>I've come up with two ways to resolve this:</p>
  
  <ul>
  <li>do this with cfoutput/group, but that's relatively ugly as it means lots of closing of cfoutputs from other parts of the page. </li>
  <li>stick a cfbreak on that third cfloop if the currentRow matches the recordcount.</li>
  </ul>
  
  <p><strong>So, two questions:</strong> </p>
  
  <ul>
  <li><p>Why is this even happening? </p></li>
  <li><p>Should I be using a totally different approach here (the fact that googling/so'ing isn't finding others with this issue certainly seems to imply that...)?</p></li>
  </ul>
  
  <p><strong>EDIT</strong>
  I've filed this as a Coldfusion bug based on Adam Cameron's feedback below. <a href="https://bugbase.adobe.com/index.cfm?event=bug&amp;id=3820049">Bug #3820049</a> </p>