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");