Leaking memory in text_overlay function

From: Dirk Rudolph <dirk(dot)rudolph(at)netcentric(dot)biz>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Leaking memory in text_overlay function
Date: 2016-07-02 12:23:35
Message-ID: 729758F1-1F95-4484-846B-994314498902@netcentric.biz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)rudolph(at)netcentric(dot)biz <mailto:dirk(dot)rudolph(at)netcentric(dot)biz> | www.netcentric.biz <http://www.netcentric.biz/>

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stefan Huehner 2016-07-02 13:10:56 9.6beta2: query failure with 'cache lookup failed for type 0'
Previous Message Christoph Berg 2016-07-02 12:11:20 Re: OpenSSL 1.1 breaks configure and more