Leaking memory in text_overlay function - Mailing list pgsql-hackers

From Dirk Rudolph
Subject Leaking memory in text_overlay function
Date
Msg-id 729758F1-1F95-4484-846B-994314498902@netcentric.biz
Whole thread Raw
Responses Re: Leaking memory in text_overlay function  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

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.

Cheers, 

Dirk Rudolph | Senior Software Engineer

Netcentric AG

M: +41 79 642 37 11
D: +49 174 966 84 34

dirk.rudolph@netcentric.biz www.netcentric.biz

Attachment

pgsql-hackers by date:

Previous
From: Christoph Berg
Date:
Subject: Re: OpenSSL 1.1 breaks configure and more
Next
From: Craig Ringer
Date:
Subject: Docs, backups, and MS VSS