while implementing my own C function, I mentioned that some memory is not freed by the text_overlay function in varlena.c
Particularly I mean the both substrings allocated by text_substring (according to the documentation of text_substring "The result is always a freshly palloc'd datum.") and one of the concatenation results. I’m aware of the MemoryContext being deleted in my case but IMHO builtin functions should be memory safe. (or at least the others I used are).
See attached a patch that fixes that against HEAD.
Description: Binary data