SAK-23555 / SAK-25792 - NPE check for loop


git-svn-id: https://source.sakaiproject.org/svn/site-manage/trunk@306472 66ffb92e-73f9-0310-93c1-f5514f145a0a