diff options
author | Miles Bader <miles@gnu.org> | 1996-01-24 03:05:35 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1996-01-24 03:05:35 +0000 |
commit | dd7cf7eed9a47db3a35461b0ba044ad6374569a5 (patch) | |
tree | a19a3cd14d54c408150b6df0645ae985ae5c475a | |
parent | a6163d2371662ec75ec71d22b148923df4ec57ad (diff) |
(sock_bind): Don't change SOCK's ref count if we're returning an error.
-rw-r--r-- | pflocal/sock.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/pflocal/sock.c b/pflocal/sock.c index b5b31639..abd04801 100644 --- a/pflocal/sock.c +++ b/pflocal/sock.c @@ -285,17 +285,18 @@ sock_bind (struct sock *sock, struct addr *addr) else old_addr->sock = NULL; /* Unbinding SOCK. */ - if (!err) - sock->addr = addr; - - if (addr) - sock->refs++; - if (old_addr) + if (! err) { - /* Note that we don't have to worry about SOCK's ref count going to zero - because whoever's calling us should be holding a ref somehow. */ - sock->refs--; - assert (sock->refs > 0); /* But make sure... */ + sock->addr = addr; + if (addr) + sock->refs++; + if (old_addr) + { + /* Note that we don't have to worry about SOCK's ref count going to + zero because whoever's calling us should be holding a ref. */ + sock->refs--; + assert (sock->refs > 0); /* But make sure... */ + } } mutex_unlock (&sock->lock); |