diff options
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/gpg-error.h.in | 30 |
2 files changed, 31 insertions, 0 deletions
@@ -5,6 +5,7 @@ Noteworthy changes in version 1.22 (unreleased) [C17/A17/R_) * Interface changes relative to the 1.20 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GPG_ERR_DB_CORRUPTED NEW. + gpgrt_annotate_leaked_object NEW inline func. Noteworthy changes in version 1.21 (2015-12-12) [C17/A17/R0] diff --git a/src/gpg-error.h.in b/src/gpg-error.h.in index b32b4c4..f0043f3 100644 --- a/src/gpg-error.h.in +++ b/src/gpg-error.h.in @@ -246,10 +246,40 @@ typedef unsigned int gpg_error_t; # define GPGRT_HAVE_PRAGMA_GCC_PUSH 1 #endif +/* Detect LeakSanitizer (LSan) support for GCC and Clang based on + * whether AddressSanitizer (ASAN) is enabled via -fsanitize=address). + * Note that -fsanitize=leak just affect the linker options which + * cannot be detected here. In that case you have to define the + * GPGRT_HAVE_LEAK_SANITIZER macro manually. */ +#ifdef __GNUC__ +# ifdef __SANITIZE_ADDRESS__ +# define GPGRT_HAVE_LEAK_SANITIZER +# elif defined(__has_feature) +# if __has_feature(address_sanitizer) +# define GPGRT_HAVE_LEAK_SANITIZER +# endif +# endif +#endif + /* The new name for the inline macro. */ #define GPGRT_INLINE GPG_ERR_INLINE +#ifdef GPGRT_HAVE_LEAK_SANITIZER +# include <sanitizer/lsan_interface.h> +#endif + +/* Mark heap objects as non-leaked memory. */ +static GPGRT_INLINE void +gpgrt_annotate_leaked_object (const void *p) +{ +#ifdef GPGRT_HAVE_LEAK_SANITIZER + __lsan_ignore_object(p); +#else + (void)p; +#endif +} + /* Initialization function. */ |