Fix an infinite loop when _fetch_read() can return 0 (if the
connection is broken), take this into account and return at this point.
This commit is contained in:
parent
15b23bddd9
commit
a6756ecc22
@ -406,6 +406,7 @@ _fetch_getln(conn_t *conn)
|
||||
char *tmp;
|
||||
size_t tmpsize;
|
||||
char c;
|
||||
int error;
|
||||
|
||||
if (conn->buf == NULL) {
|
||||
if ((conn->buf = malloc(MIN_BUF_SIZE)) == NULL) {
|
||||
@ -419,8 +420,11 @@ _fetch_getln(conn_t *conn)
|
||||
conn->buflen = 0;
|
||||
|
||||
do {
|
||||
if (_fetch_read(conn, &c, 1) == -1)
|
||||
error = _fetch_read(conn, &c, 1);
|
||||
if (error == -1)
|
||||
return (-1);
|
||||
else if (error == 0)
|
||||
break;
|
||||
conn->buf[conn->buflen++] = c;
|
||||
if (conn->buflen == conn->bufsize) {
|
||||
tmp = conn->buf;
|
||||
|
Loading…
Reference in New Issue
Block a user