]> granicus.if.org Git - libevent/commitdiff
https-client: correction error checking
authorwenyg <42307321+wenyg@users.noreply.github.com>
Thu, 30 May 2019 09:38:49 +0000 (17:38 +0800)
committerAzat Khuzhin <azat@libevent.org>
Fri, 31 May 2019 21:41:25 +0000 (00:41 +0300)
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)
sample/https-client.c

index 5869974f1bbc870b799b9e32da995e0fe0d4c5ea..58e449b1b102a205f5fff8c300be0364b871a1bd 100644 (file)
@@ -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... */