HTTPS clone URL
Subversion checkout URL
Please sign in to comment.
Fix hanging and leaks in readLine
After the last line is read from the fileDescriptor the callee will call readLine once last time. If the (uninitialized) buffer just happened to contain '\r' then this method would increment bytesReceived, then decrement it (because it has '\r' in it), then decrement it agin and assign a null byte to the byte before the buffer (stepping on who knows what). Then it would return the '\r'. Then, since it received something, the callee would call readLine again, malloc would give the same buffer it did before (with the '\r') and everything would repeat. - initialize the buffer - increment bytesReceived only if a byte is actually received - don't do any work in the loop if there were no bytes received - EINTR is a recoverable error, just reread - give the actual reason for an error rather than some random string - free the buffer when a newline is found or when there is an error
- Loading branch information...