]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: ocsp: Remove free of main structure from ssl_sock_free_ocsp_data
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Thu, 1 Oct 2026 14:59:23 +0000 (16:59 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Fri, 2 Oct 2026 11:07:55 +0000 (13:07 +0200)
The 'ssl_sock_free_ocsp_data' now only frees the contents of the
'certificate_ocsp' while leaving the actual structure unfreed.
This will allow to keep certificate_ocsp structures on the stack later.

src/ssl_ocsp.c

index 42f7d87613d0731e4ddf992e5c610f0c11263fc6..1ed6eaf99aa9cd94a2f953fd40a8c2bb667e2fb4 100644 (file)
@@ -473,7 +473,6 @@ static void ssl_sock_free_ocsp_data(struct certificate_ocsp *ocsp)
                ha_free(&ocsp->uri);
        }
        ha_free(&ocsp->last_update_error);
-       free(ocsp);
 }
 
 /*
@@ -494,8 +493,10 @@ void ssl_sock_free_ocsp(struct certificate_ocsp *ocsp)
                 * ckch_store was deleted or changed (via cli commands for
                 * instance).
                 */
-               if (ocsp->refcount <= 0)
+               if (ocsp->refcount <= 0) {
                        ssl_sock_free_ocsp_data(ocsp);
+                       free(ocsp);
+               }
        }
        HA_SPIN_UNLOCK(OCSP_LOCK, &ocsp_tree_lock);
 }
@@ -514,9 +515,10 @@ void ssl_sock_free_ocsp_instance(struct certificate_ocsp *ocsp)
                 * ckch_store was deleted or changed (via cli commands for
                 * instance).
                 */
-               if (ocsp->refcount_store <= 0)
+               if (ocsp->refcount_store <= 0) {
                        ssl_sock_free_ocsp_data(ocsp);
-
+                       free(ocsp);
+               }
        }
        HA_SPIN_UNLOCK(OCSP_LOCK, &ocsp_tree_lock);
 }