Skip to content

Commit

Permalink
Fix potential Null pointer dereference in client.c
Browse files Browse the repository at this point in the history
  • Loading branch information
icy17 committed Apr 10, 2024
1 parent 477033f commit bf6d300
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions benchmark/throughput/libevent/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ static void accept_conn_cb(struct evconnlistener *listener,
struct event_base *base = evconnlistener_get_base(listener);
struct bufferevent *bev = bufferevent_socket_new(
base, fd, BEV_OPT_CLOSE_ON_FREE);

if (bev == NULL) {
perror("Couldn't create bufferevent");
return;
}
set_tcp_no_delay(fd);

bufferevent_setcb(bev, echo_read_cb, NULL, echo_event_cb, NULL);
Expand Down Expand Up @@ -89,6 +94,10 @@ int main(int argc, char **argv)
}

evstop = evsignal_new(base, SIGHUP, signal_cb, base);
if (!evstop) {
puts("Couldn't create event");
return 1;
}
evsignal_add(evstop, NULL);

/* Clear the sockaddr before using it, in case there are extra
Expand Down

0 comments on commit bf6d300

Please sign in to comment.