Bugfix for segafult in error handling code

Error handling code segfaulted because of read-past-end-of-list.