Skip to content

Commit

Permalink
Fix potential Null pointer dereference in evhttp_client_test.cc
Browse files Browse the repository at this point in the history
  • Loading branch information
icy17 committed Apr 10, 2024
1 parent 477033f commit d53978c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/evhttp_client_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit d53978c

Please sign in to comment.