From d18fc77286cc10343220d8ea012cfe32ea190a0d Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Thu, 24 Mar 2016 10:41:22 +0100 Subject: Mark constant MPIs as non-leaked * mpi/mpiutil.c: Mark "constant" MPIs as explicitly leaked. -- Requires libgpg-error 1.22 (unreleased) for the macros, but since it is a minor debugging aid, do not bump the minimum required version. Signed-off-by: Peter Wu --- mpi/mpiutil.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c index 99402b82..142c74e0 100644 --- a/mpi/mpiutil.c +++ b/mpi/mpiutil.c @@ -61,7 +61,7 @@ _gcry_mpi_init (void) default: log_bug ("invalid mpi_const selector %d\n", idx); } constants[idx] = mpi_alloc_set_ui (value); - constants[idx]->flags = (16|32); + _gcry_mpi_set_flag(constants[idx], GCRYMPI_FLAG_CONST); } return 0; @@ -665,7 +665,12 @@ _gcry_mpi_set_flag (gcry_mpi_t a, enum gcry_mpi_flag flag) switch (flag) { case GCRYMPI_FLAG_SECURE: mpi_set_secure(a); break; - case GCRYMPI_FLAG_CONST: a->flags |= (16|32); break; + case GCRYMPI_FLAG_CONST: + a->flags |= (16|32); +#if GPGRT_VERSION_NUMBER >= 0x011600 /* 1.22 */ + gpgrt_annotate_leaked_object(a); +#endif + break; case GCRYMPI_FLAG_IMMUTABLE: a->flags |= 16; break; case GCRYMPI_FLAG_USER1: -- cgit v1.2.1