sync with upstream, fix read-past-end errors
Merge pull request #80 from client9/remotes/trunk

sync with upstream, fix read-past-end errors