summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2014-04-10 10:42:51 +0200
committerAndreas Schneider <asn@samba.org>2014-04-14 15:29:03 +0200
commitefd810d5e12e7b1409542874f5bf29ab0d431a7b (patch)
tree8cf01733a095dd3a3fd87b5c719b1eca5cf22ead /src
parent3786fdc51b18b74411a4d5cca9af2aa3ff250505 (diff)
downloadsocket_wrapper-efd810d5e12e7b1409542874f5bf29ab0d431a7b.tar.gz
socket_wrapper-efd810d5e12e7b1409542874f5bf29ab0d431a7b.tar.xz
socket_wrapper-efd810d5e12e7b1409542874f5bf29ab0d431a7b.zip
swrap: Do not leak memory in swrap_recvmsg_after().
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jakub Hrozek <jhrozek@redhat.com> Reviewed-by: Simo Sorce <idra@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/socket_wrapper.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index c5b1fdf..5ed9d9f 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -3155,7 +3155,7 @@ static int swrap_recvmsg_after(int fd,
{
int saved_errno = errno;
size_t i;
- uint8_t *buf;
+ uint8_t *buf = NULL;
off_t ofs = 0;
size_t avail = 0;
size_t remain;
@@ -3187,7 +3187,7 @@ static int swrap_recvmsg_after(int fd,
/* we capture it as one single packet */
buf = (uint8_t *)malloc(remain);
- if (!buf) {
+ if (buf == NULL) {
/* we just not capture the packet */
errno = saved_errno;
return -1;
@@ -3228,7 +3228,7 @@ static int swrap_recvmsg_after(int fd,
msg->msg_name,
&msg->msg_namelen);
if (rc == -1) {
- return -1;
+ goto done;
}
swrap_dump_packet(si,
@@ -3247,6 +3247,7 @@ static int swrap_recvmsg_after(int fd,
break;
}
+done:
free(buf);
errno = saved_errno;
return 0;