From a2c86dcbf6464634ebbc63ef1cd2966b8ef132f9 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 7 Apr 2010 18:09:39 +0000 Subject: [PATCH] Remove XXX comment and just close received fd if calloc() fails. If this happens the imsg may no longer be usable as there may be queued messages, but this is a) already the case with the code now, and b) would be the case if recvmsg() fails anyway, so we can document that -1 from imsg_read() invalidates the struct imsgbuf. discussed with and ok eric --- imsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imsg.c b/imsg.c index 263c7c8c..1be7f5ae 100644 --- a/imsg.c +++ b/imsg.c @@ -79,7 +79,7 @@ imsg_read(struct imsgbuf *ibuf) cmsg->cmsg_type == SCM_RIGHTS) { fd = (*(int *)CMSG_DATA(cmsg)); if ((ifd = calloc(1, sizeof(struct imsg_fd))) == NULL) { - /* XXX: this return can leak */ + close(fd); return (-1); } ifd->fd = fd;