about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <pochu27@gmail.com>2010-07-20 19:19:34 -0700
committerRoland McGrath <roland@redhat.com>2010-07-20 19:19:34 -0700
commit23d101d8eea76469b41c12b10a8e8ed13cf66bc6 (patch)
treec372519ace339dcddf7e9bac18aaf4196f0fe664 /sysdeps
parent5dbc3b6cc0b759bf4b22d851ccb9cbf3e3cbc6ef (diff)
downloadglibc-23d101d8eea76469b41c12b10a8e8ed13cf66bc6.tar.gz
glibc-23d101d8eea76469b41c12b10a8e8ed13cf66bc6.tar.xz
glibc-23d101d8eea76469b41c12b10a8e8ed13cf66bc6.zip
Hurd: fix sendmsg memory leak in error paths
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/mach/hurd/sendmsg.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c
index a9d1c8c1d4..118fd59a5b 100644
--- a/sysdeps/mach/hurd/sendmsg.c
+++ b/sysdeps/mach/hurd/sendmsg.c
@@ -109,14 +109,22 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
 	     and talk to it with the ifsock protocol.  */
 	  file_t file = __file_name_lookup (addr->sun_path, 0, 0);
 	  if (file == MACH_PORT_NULL)
-	    return -1;
+	    {
+	      if (dealloc)
+		__vm_deallocate (__mach_task_self (), data.addr, len);
+	      return -1;
+	    }
 	  err = __ifsock_getsockaddr (file, &aport);
 	  __mach_port_deallocate (__mach_task_self (), file);
 	  if (err == MIG_BAD_ID || err == EOPNOTSUPP)
 	    /* The file did not grok the ifsock protocol.  */
 	    err = ENOTSOCK;
 	  if (err)
-	    return __hurd_fail (err);
+	    {
+	      if (dealloc)
+		__vm_deallocate (__mach_task_self (), data.addr, len);
+	      return __hurd_fail (err);
+	    }
 	}
       else
 	err = EIEIO;