Fix segmentation fault

In case 'scan' points to 'taglist', 'next' needs to be set, because the
loop that adjusts the references (and that is supposed to set 'next')
does not execute at all.

Additionally, fix the warning message.