Lists: | Postg토토 캔SQL : Postg토토 캔SQL 메일 링리스트 : 2008-10-24 20:10 이후의 PGSQL-BUGS |
---|
From: | "" <dvice_null(at)yahoo(dot)com> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #4494: Memory leak in pg_regress.c |
Date: | 2008-10-24 20:10:38 |
Message-ID: | 200810242010.m9OKAcEj002378@wwwmaster.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg토토 캔SQL : Postg토토 캔SQL 메일 링리스트 : 2008-10-24 20:10 이후의 PGSQL-BUGS |
The following bug has been logged online:
Bug reference: 4494
Logged by:
Email address: dvice_null(at)yahoo(dot)com
PostgreSQL version: Latest cvs
Operating system: Error in source code
Description: Memory leak in pg_regress.c
Details:
In file src/test/regress/pg_regress.c:1112
It seems to me that variables "s" and "tmp" leak memory here if last_dot is
false:
static char *
get_alternative_expectfile(const char *expectfile, int i)
{
char *last_dot;
int ssize = strlen(expectfile) + 2 + 1;
char *tmp = (char *) malloc(ssize);
char *s = (char *) malloc(ssize);
strcpy(tmp, expectfile);
last_dot = strrchr(tmp, '.');
if (!last_dot)
return NULL;
*last_dot = '\0';
snprintf(s, ssize, "%s_%d.%s", tmp, i, last_dot + 1);
free(tmp);
return s;
}
From: | Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM> |
---|---|
To: | dvice_null(at)yahoo(dot)com |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #4494: Memory leak in pg_regress.c |
Date: | 2008-10-31 11:20:56 |
Message-ID: | 490AEA18.2000200@sun.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
dvice_null(at)yahoo(dot)com napsal(a):
> The following bug has been logged online:
>
> Bug reference: 4494
> Logged by:
> Email address: dvice_null(at)yahoo(dot)com
> PostgreSQL version: Latest cvs
> Operating system: Error in source code
> Description: Memory leak in pg_regress.c
> Details:
>
> In file src/test/regress/pg_regress.c:1112
>
> It seems to me that variables "s" and "tmp" leak memory here if last_dot is
> false:
>
>
> static char *
> get_alternative_expectfile(const char *expectfile, int i)
> {
> char *last_dot;
> int ssize = strlen(expectfile) + 2 + 1;
> char *tmp = (char *) malloc(ssize);
> char *s = (char *) malloc(ssize);
>
> strcpy(tmp, expectfile);
> last_dot = strrchr(tmp, '.');
> if (!last_dot)
> return NULL;
> *last_dot = '\0';
> snprintf(s, ssize, "%s_%d.%s", tmp, i, last_dot + 1);
> free(tmp);
> return s;
> }
>
OK. It seems as a bug. tmp and s should be freed when strrchr fails. Also there
is not check when malloc fails.
Zdenek
--
Zdenek Kotala Sun Microsystems
Prague, Czech Republic http://sun.com/postgresql
From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM> |
Cc: | dvice_null(at)yahoo(dot)com, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #4494: Memory leak in pg_regress.c |
Date: | 2008-11-04 16:44:19 |
Message-ID: | 20081104164419.GF3958@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
Zdenek Kotala wrote:
> dvice_null(at)yahoo(dot)com napsal(a):
>> In file src/test/regress/pg_regress.c:1112
>>
>> It seems to me that variables "s" and "tmp" leak memory here if last_dot is
>> false:
> OK. It seems as a bug. tmp and s should be freed when strrchr fails. Also
> there is not check when malloc fails.
So who's gonna send the patch?
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
From: | Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM> |
---|---|
To: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
Cc: | dvice_null(at)yahoo(dot)com, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #4494: Memory leak in pg_regress.c |
Date: | 2008-11-10 12:31:50 |
Message-ID: | 491829B6.2090800@sun.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
Alvaro Herrera napsal(a):
> Zdenek Kotala wrote:
>> dvice_null(at)yahoo(dot)com napsal(a):
>
>>> In file src/test/regress/pg_regress.c:1112
>>>
>>> It seems to me that variables "s" and "tmp" leak memory here if last_dot is
>>> false:
>
>> OK. It seems as a bug. tmp and s should be freed when strrchr fails. Also
>> there is not check when malloc fails.
>
> So who's gonna send the patch?
I will do that. Still on my TODO.
Zdenek
From: | Bruce Momjian <bruce(at)momjian(dot)us> |
---|---|
To: | dvice_null(at)yahoo(dot)com |
Cc: | pgsql-bugs(at)postgresql(dot)org, dvice_null(at)yahoo(dot)com |
Subject: | Re: BUG #4494: Memory leak in pg_regress.c |
Date: | 2009-01-08 20:09:54 |
Message-ID: | 200901082009.n08K9sQ13969@momjian.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-bugs |
Patch written, attached, and applied.
---------------------------------------------------------------------------
dvice_null(at)yahoo(dot)com wrote:
>
> The following bug has been logged online:
>
> Bug reference: 4494
> Logged by:
> Email address: dvice_null(at)yahoo(dot)com
> PostgreSQL version: Latest cvs
> Operating system: Error in source code
> Description: Memory leak in pg_regress.c
> Details:
>
> In file src/test/regress/pg_regress.c:1112
>
> It seems to me that variables "s" and "tmp" leak memory here if last_dot is
> false:
>
>
> static char *
> get_alternative_expectfile(const char *expectfile, int i)
> {
> char *last_dot;
> int ssize = strlen(expectfile) + 2 + 1;
> char *tmp = (char *) malloc(ssize);
> char *s = (char *) malloc(ssize);
>
> strcpy(tmp, expectfile);
> last_dot = strrchr(tmp, '.');
> if (!last_dot)
> return NULL;
> *last_dot = '\0';
> snprintf(s, ssize, "%s_%d.%s", tmp, i, last_dot + 1);
> free(tmp);
> return s;
> }
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
Attachment | Content-Type | Size |
---|---|---|
/rtmp/diff | text/x-diff | 623 bytes |