Page MenuHome GnuPG

curses: Avoid including system <memory.h> header

Authored by chrstphrchvz on Mar 20 2023, 4:57 AM.



On macOS and other BSD OSes, there exists a memory.h system header (which just includes <string.h>). pinentry/pinentry-curses.c should include pinentry’s own memory.h using #include "memory.h" (as already done elsewhere in pinentry) rather than #include <memory.h> to prevent a system memory.h header from taking precedence and leading to implicit declaration of secmem_free() (which Xcode clang 12 and LLVM clang 16 consider an error by default rather than a warning).

This issue was observed by MacPorts (see for the defunct pinentry-mac fork, which is where I originally tried submitting this change to (see

Test Plan

I am not aware of what I should put here. This change is already successfully in use downstream on macOS, so I am just submitting it here for consideration by upstream.

Diff Detail

rP Pinentry
Lint Skipped
Unit Tests Skipped

Event Timeline

chrstphrchvz created this revision.
werner added a subscriber: werner.

This header was introduced close to 20 years ago. I agree that it does not make any sense - it might be a left-over from an old Hurd version. We can entirely remove it because string.h is already included and we also don't use memory.h anywhere in gnupg proper.

This revision is now accepted and ready to land.Mar 20 2023, 8:10 AM

Turned out to be a bit come complicated. I hope that I did not break any of the other pinentries: