]> granicus.if.org Git - libevent/commitdiff
https-client: do not try to free not initialized base
authorAzat Khuzhin <azat@libevent.org>
Wed, 3 Apr 2019 20:22:54 +0000 (23:22 +0300)
committerAzat Khuzhin <azat@libevent.org>
Wed, 3 Apr 2019 20:24:17 +0000 (23:24 +0300)
Otherwise:
  $ https-client --help
  Syntax:
     https-client -url <https-url> [-data data-file.bin] [-ignore-cert] [-retries num] [-timeout sec] [-crt crt]
  Example:
     https-client -url https://ip.appspot.com/
  [warn] event_base_free_: no base to free

sample/https-client.c

index 4292f0942b5a0cceac1b7a1e511d78a62a89ecc8..5869974f1bbc870b799b9e32da995e0fe0d4c5ea 100644 (file)
@@ -45,7 +45,6 @@
 
 #include "openssl_hostname_validation.h"
 
-static struct event_base *base;
 static int ignore_cert = 0;
 
 static void
@@ -188,7 +187,7 @@ int
 main(int argc, char **argv)
 {
        int r;
-
+       struct event_base *base = NULL;
        struct evhttp_uri *http_uri = NULL;
        const char *url = NULL, *data_file = NULL;
        const char *crt = NULL;
@@ -483,7 +482,8 @@ cleanup:
                evhttp_connection_free(evcon);
        if (http_uri)
                evhttp_uri_free(http_uri);
-       event_base_free(base);
+       if (base)
+               event_base_free(base);
 
        if (ssl_ctx)
                SSL_CTX_free(ssl_ctx);