From: Mark Wooding Date: Sat, 20 Oct 2012 12:54:12 +0000 (+0100) Subject: yaid.c: Reorder `proxy_query': don't use `c' after `conn_init'. X-Git-Tag: 1.0.0~14 X-Git-Url: https://git.distorted.org.uk/~mdw/yaid/commitdiff_plain/79805e61788e52f2cf8b6563b3656d5e40529d09 yaid.c: Reorder `proxy_query': don't use `c' after `conn_init'. 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). --- diff --git a/yaid.c b/yaid.c index bdfdd93..fc6ddd4 100644 --- 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: