CID 20463 & 20464 Wrong sizeof argument (SIZEOF_MISMATCH)
CID-20535: Dereference null return value (NULL_RETURNS)
Fixed CID-13261 broken memcpy()

We actually intentionally leak the stream resources so we don't actually
need to copy the content of the context, only the pointer
CID 20060: Resource leak (RESOURCE_LEAK)
CID 19803 / 19802 / 19737 free error_message on failure
CID 19738 (and probably others) freeing error_message on failure

...Also, actually fail when we can't read all the data we were supposed to be able to
(eg. the network cable is ripped out after we get the header!)
Fix error codes
Merge pull request #654 from bjori/QA-coverity

Coverity fixes

* bjori/QA-coverity:
  Fix error codes
  CID 19738 (and probably others) freeing error_message on failure
  CID 19803 / 19802 / 19737 free error_message on failure
  CID 20060: Resource leak (RESOURCE_LEAK)
  Fixed CID-13261 broken memcpy()
  CID-20535: Dereference null return value (NULL_RETURNS)
  CID 20463 & 20464 Wrong sizeof argument (SIZEOF_MISMATCH)