Fix array overrun when new items are appended to a result set.

Check the correct iterator in the loop guard.

Change-Id: I1b6092febdc09ca908e9fab1716d98c3ebd6ec6f
Reviewed-by: Christopher Adams <chris.adams@jollamobile.com>