]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-upload: cleanup CURL* on error
authorDavid Tardon <dtardon@redhat.com>
Wed, 17 Mar 2021 09:22:15 +0000 (10:22 +0100)
committerDavid Tardon <dtardon@redhat.com>
Thu, 18 Mar 2021 08:41:49 +0000 (09:41 +0100)
src/journal-remote/journal-upload.c

index e56e336b4f7ecae14fdef81df888cb5ae53069bb..9a7a4e92a42e50699a61f81a6643f1295b752e41 100644 (file)
@@ -71,6 +71,8 @@ static void close_fd_input(Uploader *u);
                 }                                                       \
         } while (0)
 
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CURL*, curl_easy_cleanup, NULL);
+
 static size_t output_callback(char *buf,
                               size_t size,
                               size_t nmemb,
@@ -202,7 +204,7 @@ int start_upload(Uploader *u,
         }
 
         if (!u->easy) {
-                CURL *curl;
+                _cleanup_(curl_easy_cleanupp) CURL *curl = NULL;
 
                 curl = curl_easy_init();
                 if (!curl)
@@ -260,7 +262,7 @@ int start_upload(Uploader *u,
                         easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1,
                                     LOG_WARNING, );
 
-                u->easy = curl;
+                u->easy = TAKE_PTR(curl);
         } else {
                 /* truncate the potential old error message */
                 u->error[0] = '\0';