Fixed bug #4973: Check if array is empty before looping over it (thanks to Thomas...