Move error handling code to avoid undefined behavior.
Move error handling code to avoid undefined behavior.

rimms/jubatus,Asuka52/jubatus,gintenlabo/jubatus,elkingtonmcb/jubatus,jubatus/jubatus,gintenlabo/jubatus,mathn/jubatus,roselleebarle04/jubatus,kmaehashi/jubatus,elkingtonmcb/jubatus,Asuka52/jubatus,rimms/jubatus,roselleebarle04/jubatus,mathn/jubatus,kmaehashi/jubatus,jubatus/jubatus,jubatus/jubatus