Found by nfsim.
I knew about this, but as we stop when it happens anyway I didn't fix
it. But it bugs nfsim, so fix it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
/* Finished. But maybe this was just header? */
if (io->len == sizeof(*hdr) && hdr->length > io->len) {
int reret;
+ void *newdata;
/* Enlarge and re-read. */
io->len = hdr->length;
- io->data = realloc(io->data, io->len);
- if (!io->data)
+ newdata = realloc(io->data, io->len);
+ if (!newdata)
return -1;
+ io->data = newdata;
/* Try reading again immediately. */
reret = read_io_elem(fd, io);
if (reret >= 0)