summaryrefslogtreecommitdiff
path: root/src/g10lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/g10lib.h')
-rw-r--r--src/g10lib.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/g10lib.h b/src/g10lib.h
index 50a08ec8..5793f8ca 100644
--- a/src/g10lib.h
+++ b/src/g10lib.h
@@ -88,6 +88,16 @@
#define DIM(v) (sizeof(v)/sizeof((v)[0]))
#define DIMof(type,member) DIM(((type *)0)->member)
+/* Detect LeakSanitizer (LSan) support for GCC and Clang based on the
+ availability of AddressSanitizer (ASAN). */
+#ifdef __SANITIZE_ADDRESS__
+# define LEAK_SANITIZER
+#elif defined(__has_feature)
+# if __has_feature(address_sanitizer)
+# define LEAK_SANITIZER
+# endif
+#endif
+
/*-- src/global.c -*/
@@ -126,6 +136,13 @@ int _gcry_is_secure (const void *a) _GCRY_GCC_ATTR_PURE;
#define xstrdup(a) _gcry_xstrdup ((a))
#define xfree(a) _gcry_free ((a))
+/* Allows "constant" MPIs to be annotated as memory leak. */
+#ifdef LEAK_SANITIZER
+# include <sanitizer/lsan_interface.h>
+# define annotate_leaked_object(a) __lsan_ignore_object((a))
+#else
+# define annotate_leaked_object(a) do { } while (0)
+#endif
/*-- src/misc.c --*/