From 5cc6b22736b2264b176e1dedc8528bd5ee2f7e80 Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sun, 21 Jul 2013 19:39:41 +0800 Subject: [PATCH] fix a potential dangling pointer --- src/server.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/server.c b/src/server.c index b6cc7808..baaf728b 100644 --- a/src/server.c +++ b/src/server.c @@ -872,15 +872,15 @@ int main (int argc, char **argv) { LOGD("server listening at port %s.", server_port); // Setup proxy context - struct listen_ctx listen_ctx; - listen_ctx.timeout = atoi(timeout); - listen_ctx.asyncns = asyncns; - listen_ctx.fd = listenfd; - listen_ctx.method = m; - listen_ctx.iface = iface; - - ev_io_init (&listen_ctx.io, accept_cb, listenfd, EV_READ); - ev_io_start (loop, &listen_ctx.io); + struct listen_ctx *listen_ctx = malloc(sizeof(struct listen_ctx)); + listen_ctx->timeout = atoi(timeout); + listen_ctx->asyncns = asyncns; + listen_ctx->fd = listenfd; + listen_ctx->method = m; + listen_ctx->iface = iface; + + ev_io_init (&listen_ctx->io, accept_cb, listenfd, EV_READ); + ev_io_start (loop, &listen_ctx->io); } // start ev loop