[PATCH] Mark constant MPIs as non-leaked

Peter Wu peter at lekensteyn.nl
Thu Mar 24 11:06:23 CET 2016


* 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 <peter at lekensteyn.nl>
---
Hi,

Thanks Werner for the quick the libgpg-error feedback (merged). Minor
observation about the libgpg-error NEWS file, it should say "Interface changes
relative to the 1.21 release" instead of "1.20".

After this and two other (proposed) patches ("Fix memleaks in (self)tests." and
"Avoid undefined behavior for hashes using XOF"), the only UBSan report (for
make check) that remains to be fixed is https://bugs.gnupg.org/gnupg/issue2292.

Kind regards,
Peter
---
 mpi/mpiutil.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c
index 99402b8..6dee0b9 100644
--- a/mpi/mpiutil.c
+++ b/mpi/mpiutil.c
@@ -211,7 +211,12 @@ _gcry_mpi_free( gcry_mpi_t a )
   if (!a )
     return;
   if ((a->flags & 32))
+  {
+#if GPGRT_VERSION_NUMBER >= 0x011600  /* 1.22 */
+    gpgrt_annotate_leaked_object(a);
+#endif
     return; /* Never release a constant. */
+  }
   if ((a->flags & 4))
     xfree( a->d );
   else
-- 
2.7.4




More information about the Gcrypt-devel mailing list