BUG #4493: Memory leak in informix.c

Lists: Postg윈 토토SQL : Postg윈 토토SQL 메일 링리스트 : 2008-10-24 이후 PGSQL-BUGS 20:04
From: "" <dvice_null(at)yahoo(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #4493: Memory leak in informix.c
Date: 2008-10-24 20:04:24
Message-ID: 200810242004.m9OK4OfL098056@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: Postg윈 토토SQL : Postg윈 토토SQL 메일 링리스트 : 2008-10-24 이후 PGSQL-BUGS 20:04


The following bug has been logged online:

Bug reference: 4493
Logged by:
Email address: dvice_null(at)yahoo(dot)com
PostgreSQL version: Latest cvs
Operating system: Error in source code
Description: Memory leak in informix.c
Details:

In file src/interfaces/ecpg/compatlib/informix.c:763

It seems to me that variable "temp" leaks memory here if initValue() fails:

temp = (char *) malloc(fmt_len + 1);

/* put all info about the long in a struct */
if (!temp || initValue(lng_val) == -1)
{
errno = ENOMEM;
return -1;
}


From: Michael Meskes <meskes(at)postgresql(dot)org>
To: dvice_null(at)yahoo(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4493: Memory leak in informix.c
Date: 2008-10-25 14:43:38
Message-ID: 20081025144338.GA10482@feivel.credativ.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Fri, Oct 24, 2008 at 08:04:24PM +0000, dvice_null(at)yahoo(dot)com wrote:
> In file src/interfaces/ecpg/compatlib/informix.c:763
>
> It seems to me that variable "temp" leaks memory here if initValue() fails:
>
> temp = (char *) malloc(fmt_len + 1);
>
> /* put all info about the long in a struct */
> if (!temp || initValue(lng_val) == -1)
> {
> errno = ENOMEM;
> return -1;
> }

Technically you're right and I will fix this in CVS. However, I doubt this
has any impact at all because there is only one failure possible in initValue
and that's ENOMEM. So an application might not free all its memory if it ever
runs out of memory. But given that the latter case will probably result in the
application being terminated the effect is nil for almost all use cases.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!