Re: Small memory leak in execute.c of ECPG driver

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
Cc: PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Small memory leak in execute.c of ECPG driver
Date: 2015-02-03 12:45:36
Message-ID: CAB7nPqTdaXhdA8Cb=M=r=gJ-o-mD78+KNRM2x4L_vcHO-+Uk5g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 3, 2015 at 5:35 PM, Heikki Linnakangas
<hlinnakangas(at)vmware(dot)com> wrote:
> I think there are more similar leaks nearby. After the first hunk, there's
> another if-check with "return false" that also leaks mallocedval. Right
> after the two other hunks, if the ecpg_realloc fails, we again leak
> mallocedval.
Yes, I found some extra ones by re-reading the code again with newcopy
(2) as well as mallocedval (1) as you mentioned.

> I wonder why Coverity didn't warn about those? Maybe it would've, after
> fixing the first ones.
Hard to say. Perhaps it gives up after finding one failure in a code
path, or perhaps it would have found it after a version update.. In
any case, an updated patch is attached.
--
Michael

Attachment Content-Type Size
20150203_ecpg_leakfix_v2.patch application/x-patch 2.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2015-02-03 12:51:25 Re: Getting rid of wal_level=archive and default to hot_standby + wal_senders
Previous Message Andres Freund 2015-02-03 12:43:17 Getting rid of wal_level=archive and default to hot_standby + wal_senders