Ticket #6187: Avoid infinite loop if eraseDeadCode does not remove anything (this time without memory corruption).

Hi,

This PR is a follow-up to https://github.com/danmar/cppcheck/pull/450/ that fixed the bug but introduced a memory corruption, and was therefore reverted (sorry about this!). This new version is a bit more clever and valgrind is now happy. Please consider merging.

Cheers,
  Simon