From a8a04565b15548678c79eb67f0bfd63a188ff1fb Mon Sep 17 00:00:00 2001 From: wenyg <42307321+wenyg@users.noreply.github.com> Date: Thu, 30 May 2019 17:38:49 +0800 Subject: [PATCH] https-client: correction error checking When connecting to a non-existent HTTPS service, the "req" is not null but the "evhttp_request_get_response_code(req)" is zero. Closes: #822 (cherry-picked) (cherry picked from commit 891dd1880fed8c5e1e98f122daeb1ae8414f6b1c) --- sample/https-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample/https-client.c b/sample/https-client.c index 5869974f..58e449b1 100644 --- a/sample/https-client.c +++ b/sample/https-client.c @@ -53,7 +53,7 @@ http_request_done(struct evhttp_request *req, void *ctx) char buffer[256]; int nread; - if (req == NULL) { + if (!req || !evhttp_request_get_response_code(req)) { /* If req is NULL, it means an error occurred, but * sadly we are mostly left guessing what the error * might have been. We'll do our best... */