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 |
Thread: | |
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 | Date | Subject | |
---|---|---|---|
Next Message | Francisco Olarte Sanz | 2008-10-31 13:52:02 | Re: BUG #4496: Memory leak in pg_dump.c? |
Previous Message | Zdenek Kotala | 2008-10-31 11:18:36 | Re: BUG #4496: Memory leak in pg_dump.c? |