Fixed PHP-704: Incorrect failure checks for stream reads

get_cursor_body() returns 0 on failure. I reviewed all other instances
of similar calls and they all look fine.
On failure, we also need to free the error message after throwing the
exception
De-yodafied.
Merged pull request #318