From 3c31441620883c012f4192b26d393e63a89c1236 Mon Sep 17 00:00:00 2001 From: icy17 <1061499390@qq.com> Date: Wed, 10 Apr 2024 18:55:40 +0800 Subject: [PATCH] Fix potential Null pointer dereference in client.c --- benchmark/throughput/libevent/client.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/benchmark/throughput/libevent/client.c b/benchmark/throughput/libevent/client.c index 3bf6678b4..dc46f85d1 100644 --- a/benchmark/throughput/libevent/client.c +++ b/benchmark/throughput/libevent/client.c @@ -83,6 +83,10 @@ int main(int argc, char **argv) } evtimeout = evtimer_new(base, timeoutcb, base); + if (evtimeout == NULL) { + puts("error create event"); + return -1; + } evtimer_add(evtimeout, &timeout); memset(&sin, 0, sizeof(sin)); @@ -93,7 +97,10 @@ int main(int argc, char **argv) bevs = malloc(session_count * sizeof(struct bufferevent *)); for (i = 0; i < session_count; ++i) { struct bufferevent *bev = bufferevent_socket_new(base, -1, BEV_OPT_CLOSE_ON_FREE); - + if (bev == NULL) { + puts("error create bufferevent"); + return -1; + } bufferevent_setcb(bev, readcb, NULL, eventcb, NULL); bufferevent_enable(bev, EV_READ|EV_WRITE); evbuffer_add(bufferevent_get_output(bev), message, block_size);