MemoryDealer: Avoid using invalid iterator

'pos' is invalidated by the call to erase(), so we no longer
want to use it.  Instead, we reassign 'pos' to the result of
erase(), which a valid iterator.  Since that result could be
mList.end(), and since we would otherwise perform a '++pos',
we add a new check against mList.end() to break out of our
do/while loop.  Since we'll invoke the "return freed" path,
we don't need to be worried about the outer 'for' loop
incrementing 'pos' beyond the end.

Test: TreeHugger
Change-Id: Iade7ed4077318840aca9da3a4196c268c9080e7c
1 file changed