]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: http-client-request - Make http_client_request_unref(NULL) a no-op
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 20 Nov 2024 00:53:25 +0000 (01:53 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 7 Mar 2025 14:56:56 +0000 (14:56 +0000)
src/lib-http/http-client-request.c

index 3e310bdb4cf971a53b047927c723365633692b73..d640978c50654c9c5311be0efc2bfb8cbfab2510 100644 (file)
@@ -312,15 +312,17 @@ void http_client_request_ref(struct http_client_request *req)
 bool http_client_request_unref(struct http_client_request **_req)
 {
        struct http_client_request *req = *_req;
-       struct http_client *client = req->client;
-
-       i_assert(req->refcount > 0);
 
+       if (req == NULL)
+               return FALSE;
        *_req = NULL;
 
+       i_assert(req->refcount > 0);
        if (--req->refcount > 0)
                return TRUE;
 
+       struct http_client *client = req->client;
+
        if (client == NULL) {
                e_debug(req->event, "Free (client already destroyed)");
        } else {