From fa5e833a50c1e18cee29ca7fb660cc423904a024 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 27 Nov 2011 23:03:15 +0100 Subject: Fix source address reference accounting * libpipe/pipe.c (pipe_recv): If `source' is NULL but packet source exists, dereference it. * pflocal/io.c (S_io_write): Only dereference the source on errors. --- libpipe/pipe.c | 2 ++ pflocal/io.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libpipe/pipe.c b/libpipe/pipe.c index 914816bc..4580b3ab 100644 --- a/libpipe/pipe.c +++ b/libpipe/pipe.c @@ -383,6 +383,8 @@ pipe_recv (struct pipe *pipe, int noblock, unsigned *flags, void **source, if (source) packet_read_source (packet, source); + else if (packet->source) + pipe_dealloc_addr(packet->source); err = (*pipe->class->read)(packet, &dq, flags, data, data_len, amount); diff --git a/pflocal/io.c b/pflocal/io.c index 74c2f970..36221a66 100644 --- a/pflocal/io.c +++ b/pflocal/io.c @@ -106,7 +106,7 @@ S_io_write (struct sock_user *user, { err = pipe_write (pipe, user->sock->flags & SOCK_NONBLOCK, source_addr, data, data_len, amount); - if (source_addr) + if (err && source_addr) ports_port_deref (source_addr); } -- cgit v1.2.3