Fix segfault on embedded list iteration

Close #3490