bug fix

fixed memory leak in api_stream_unread, and on wondows also
saved/restored posix errno