fix warning: cannot optimize possibly infinite loops [-Wunsafe-loop-optimizations]

Signed-off-by: Mattias Andrée <maandree@operamail.com>