This will go poorly when rm_aff = rm_aff->next executes again. You need to store the next affect before potentially deleting it, then change the loop update to rm_aff = next_aff.