fix a potential dangling pointer

This commit is contained in:
Max Lv
2013-07-21 19:41:22 +08:00
parent 5846e389e1
commit 5cc6b22736
+8 -8
View File
@@ -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;
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);
ev_io_init (&listen_ctx->io, accept_cb, listenfd, EV_READ);
ev_io_start (loop, &listen_ctx->io);
}
// start ev loop