]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
ocsp: suppress false-positive reported by GCC 15 analyzer
authorDaiki Ueno <ueno@gnu.org>
Thu, 22 Jan 2026 09:32:47 +0000 (18:32 +0900)
committerDaiki Ueno <ueno@gnu.org>
Fri, 6 Feb 2026 11:07:13 +0000 (20:07 +0900)
GCC 15 analyzer reports:

  ocsp.c:2470:17: warning: dereference of NULL '*ocsps' [CWE-476] [-Wanalyzer-null-dereference]
   2470 |                 gnutls_ocsp_resp_deinit((*ocsps)[i]);
        |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

*ocsps should always be non-NULL when this part is exercised. This
adds an assertion for that.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
lib/x509/ocsp.c

index 0120129d50374c08887420caca1e68b4969c466b..1ed3c05206b5605fc74344d79f8958e15de6068d 100644 (file)
@@ -2466,6 +2466,7 @@ int gnutls_ocsp_resp_list_import2(gnutls_ocsp_resp_t **ocsps,
        goto cleanup;
 
 fail:
+       assert((*size == 0 && *ocsps == NULL) || (*size > 0 && *ocsps != NULL));
        for (i = 0; i < *size; i++) {
                gnutls_ocsp_resp_deinit((*ocsps)[i]);
        }