You are incrementing rdi
inside the loop as well as in the for
declaration:
for (; rdi != end_rdi; rdi++)
{
rdi++;
That means that rdi
might be end_rdi
(the end-iterator, which means past the last element) within your loop. Is there any reason you're doing this? (If this is intentional, you should check to make sure rdi != end_rdi
again after you increment it.)