Coverity-found bug: don't use temp->next *before* checking it for NULL. Also return rather than use it again.
Coverity-found bug: don't use temp->next *before* checking it for NULL. Also
return rather than use it again.

sk-/python2.7-type-annotator,sk-/python2.7-type-annotator,sk-/python2.7-type-annotator