]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-gatewayd: use automatic cleanup
authorDavid Tardon <dtardon@redhat.com>
Wed, 17 Mar 2021 09:05:47 +0000 (10:05 +0100)
committerDavid Tardon <dtardon@redhat.com>
Thu, 18 Mar 2021 08:41:46 +0000 (09:41 +0100)
src/journal-remote/journal-gatewayd.c

index 86df022b64aa64729f23f779210061057a4882df..4cefe3918c9d60dc4180dc7cbd9fa3c8f0d28a07 100644 (file)
@@ -641,7 +641,7 @@ static int request_handler_redirect(
                 struct MHD_Connection *connection,
                 const char *target) {
 
-        char *page;
+        _cleanup_free_ char *page = NULL;
         _cleanup_(MHD_destroy_responsep) struct MHD_Response *response = NULL;
 
         assert(connection);
@@ -651,10 +651,9 @@ static int request_handler_redirect(
                 return respond_oom(connection);
 
         response = MHD_create_response_from_buffer(strlen(page), page, MHD_RESPMEM_MUST_FREE);
-        if (!response) {
-                free(page);
+        if (!response)
                 return respond_oom(connection);
-        }
+        TAKE_PTR(page);
 
         if (MHD_add_response_header(response, "Content-Type", "text/html") == MHD_NO ||
             MHD_add_response_header(response, "Location", target) == MHD_NO)