From d53978ca1701a4f81197abc77f67cafa533dd571 Mon Sep 17 00:00:00 2001 From: icy17 <1061499390@qq.com> Date: Wed, 10 Apr 2024 19:05:45 +0800 Subject: [PATCH] Fix potential Null pointer dereference in evhttp_client_test.cc --- test/evhttp_client_test.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/evhttp_client_test.cc b/test/evhttp_client_test.cc index 3bfe3756a..eb588b0cc 100644 --- a/test/evhttp_client_test.cc +++ b/test/evhttp_client_test.cc @@ -23,11 +23,17 @@ void http_request_done(struct evhttp_request* req, void* arg) { TEST_UNIT(evhttpClientSample) { struct event_base* base = event_base_new(); + if (base == NULL) { + return; + } #if defined(EVPP_HTTP_CLIENT_SUPPORTS_SSL) struct evhttp_connection* conn = evhttp_connection_base_new(base, nullptr, "www.360.cn", 443); #else struct evhttp_connection* conn = evhttp_connection_base_new(base, nullptr, "www.360.cn", 80); #endif + if (conn == NULL) { + return; + } struct evhttp_request* req = evhttp_request_new(http_request_done, base); // will be free by evhttp_connection evhttp_add_header(req->output_headers, "Host", "www.360.cn"); evhttp_make_request(conn, req, EVHTTP_REQ_GET, "/robots.txt");