1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

libctdb: fix io_elem resource leak on realloc failure.

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>


(This used to be ctdb commit 936b02443d36306407d6a26e8037cf31e3190b32)
This commit is contained in:
Rusty Russell 2010-06-18 15:48:48 +09:30
parent 9f6d34150d
commit 3d126e8c14

View File

@ -110,11 +110,13 @@ int read_io_elem(int fd, struct io_elem *io)
/* 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)