]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
rnd: use matching allocator for gnutls_free
authorDaiki Ueno <ueno@gnu.org>
Thu, 22 Jan 2026 07:59:33 +0000 (16:59 +0900)
committerDaiki Ueno <ueno@gnu.org>
Fri, 6 Feb 2026 11:07:13 +0000 (20:07 +0900)
Spotted by GCC 15 analyzer:

  ./../includes/gnutls/gnutls.h:2321:24: warning: memory allocated with 'calloc' should be deallocated with 'gnutls_free' but was deallocated with 'gnutls_free'
   2321 | #define gnutls_free(a) gnutls_free((void *)(a)), a = NULL
        |                        ^~~~~~~~~~~~~~~~~~~~~~~~
  rnd.c:166:9: note: in expansion of macro 'gnutls_free'
    166 |         gnutls_free(ctx);
        |         ^~~~~~~~~~~

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

index cf4cd8a450d3b6f1c91d4eb81234043182d77cd9..1607addb52e24afd7f80552168a34a10e3d93804 100644 (file)
@@ -134,7 +134,7 @@ static int wrap_nettle_rnd_init(void **_ctx)
        uint8_t new_key[PRNG_KEY_SIZE * 2];
        struct generators_ctx_st *ctx;
 
-       ctx = calloc(1, sizeof(*ctx));
+       ctx = gnutls_calloc(1, sizeof(*ctx));
        if (ctx == NULL)
                return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);