diff --git a/src/ckpool.c b/src/ckpool.c index 859b36cc..45b3c4bc 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -150,6 +150,7 @@ int read_socket_line(connsock_t *cs, int timeout) while (42) { char readbuf[PAGESIZE] = {}; + char *ptr; FD_ZERO(&rd); FD_SET(cs->fd, &rd); @@ -173,9 +174,10 @@ int read_socket_line(connsock_t *cs, int timeout) } buflen = cs->bufofs + ret + 1; align_len(&buflen); - cs->buf = realloc(cs->buf, buflen); - if (unlikely(!cs->buf)) + ptr = realloc(cs->buf, buflen); + if (unlikely(!ptr)) quit(1, "Failed to alloc buf of %d bytes in read_socket_line", (int)buflen); + cs->buf = ptr; memcpy(cs->buf + cs->bufofs, readbuf, ret); eom = strchr(cs->buf, '\n'); cs->bufofs += ret;