Rfc6810 bis

pull request for reviewing code
use a goto error handler here, instead of a else branch.