diff --git a/lib/defines.h b/lib/defines.h index d01f691e..7950cdfa 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -330,6 +330,12 @@ extern char *strerror (); /* Maximum length of passwd entry */ #define PASSWD_ENTRY_MAX_LENGTH 32768 +#if (__GNUC__ >= 11) && !defined(__clang__) +# define ATTR_MALLOC(deallocator) [[gnu::malloc(deallocator)]] +#else +# define ATTR_MALLOC(deallocator) +#endif + #ifdef HAVE_SECURE_GETENV # define shadow_getenv(name) secure_getenv(name) # else diff --git a/lib/prototypes.h b/lib/prototypes.h index 4c293aff..885c7391 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -47,7 +47,7 @@ extern int expire (const struct passwd *, /*@null@*/const struct spwd *); /* agetpass.c */ extern void erase_pass(char *pass); -[[gnu::malloc(erase_pass)]] +ATTR_MALLOC(erase_pass) extern char *agetpass(const char *prompt); /* isexpired.c */