yaid.c: Reorder `proxy_query': don't use `c' after `conn_init'.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 20 Oct 2012 12:54:12 +0000 (13:54 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 21 Oct 2012 15:08:58 +0000 (16:08 +0100)
It might have been freed if the connection completes immediately (so
`proxy_connected' is called synchronously) and then something goes
wrong (so `c' will be freed).

yaid.c

diff --git a/yaid.c b/yaid.c
index bdfdd93..fc6ddd4 100644 (file)
--- a/yaid.c
+++ b/yaid.c
@@ -380,6 +380,8 @@ static void proxy_query(struct client *c)
   s.port = 113;
   c->l->ao->socket_to_sockaddr(&s, &ss, &ssz);
   selbuf_disable(&c->b);
+  c->px = px; px->c = c;
+  px->fd = -1;
   if (conn_init(&px->cn, &sel, fd, (struct sockaddr *)&ss, ssz,
                proxy_connected, px)) {
     logmsg(&c->q, LOG_ERR, "failed to make %s proxy connection to %s: %s",
@@ -387,8 +389,6 @@ static void proxy_query(struct client *c)
     goto err_2;
   }
 
-  c->px = px; px->c = c;
-  px->fd = -1;
   return;
 
 err_2: