Re: PostgreSQL 7.0.3: Memory leak in ESQL library - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: PostgreSQL 7.0.3: Memory leak in ESQL library
Date
Msg-id 200101022202.RAA06871@candle.pha.pa.us
Whole thread Raw
In response to PostgreSQL 7.0.3: Memory leak in ESQL library  (Thorsten Knabe <tek@thorsten-knabe.de>)
List pgsql-bugs
Yes, I see the problem you reported.  Here is the patch I have applied.
Thanks.

> Hello,
>
> I've found a memory leak in libecpg of PostgreSQL 7.0.3.
> The leak is caused by the memory allocation in
> src/interfaces/ecpg/lib/execute.c in line 669 which is never freed.
> Adding a "free(array_query);" after PQexec in line 671 seems to fix the
> leak.
>
> Regards
> Thorsten
>
> --
>               E-Mail: tek@thorsten-knabe.de
> ___              WWW: http://tek.thorsten-knabe.de
>  |        | /    ICQ: 5472045
>  |horsten |/\nabe     Linux AD1816 sound driver developer
>
>


--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
? config.log
? config.cache
? config.status
? GNUmakefile
? doc/src/sgml/ttypd
? src/Makefile.custom
? src/GNUmakefile
? src/Makefile.global
? src/log
? src/crtags
? src/backend/postgres
? src/backend/catalog/global.description
? src/backend/catalog/global.bki
? src/backend/catalog/template1.bki
? src/backend/catalog/template1.description
? src/backend/port/Makefile
? src/bin/initdb/initdb
? src/bin/initlocation/initlocation
? src/bin/ipcclean/ipcclean
? src/bin/pg_config/pg_config
? src/bin/pg_ctl/pg_ctl
? src/bin/pg_dump/pg_dump
? src/bin/pg_dump/pg_restore
? src/bin/pg_dump/pg_dumpall
? src/bin/pg_id/pg_id
? src/bin/pg_passwd/pg_passwd
? src/bin/pgaccess/pgaccess
? src/bin/pgtclsh/Makefile.tkdefs
? src/bin/pgtclsh/Makefile.tcldefs
? src/bin/pgtclsh/pgtclsh
? src/bin/pgtclsh/pgtksh
? src/bin/psql/psql
? src/bin/scripts/createlang
? src/include/config.h
? src/include/stamp-h
? src/interfaces/ecpg/lib/libecpg.so.3.2.0
? src/interfaces/ecpg/preproc/ecpg
? src/interfaces/libpgeasy/libpgeasy.so.2.1
? src/interfaces/libpgtcl/libpgtcl.so.2.1
? src/interfaces/libpq/libpq.so.2.1
? src/interfaces/perl5/blib
? src/interfaces/perl5/Makefile
? src/interfaces/perl5/pm_to_blib
? src/interfaces/perl5/Pg.c
? src/interfaces/perl5/Pg.bs
? src/pl/plperl/blib
? src/pl/plperl/Makefile
? src/pl/plperl/pm_to_blib
? src/pl/plperl/SPI.c
? src/pl/plperl/plperl.bs
? src/pl/plpgsql/src/libplpgsql.so.1.0
? src/pl/tcl/Makefile.tcldefs
Index: src/interfaces/ecpg/lib/execute.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/ecpg/lib/execute.c,v
retrieving revision 1.15
diff -c -r1.15 execute.c
*** src/interfaces/ecpg/lib/execute.c    2000/12/18 11:33:54    1.15
--- src/interfaces/ecpg/lib/execute.c    2001/01/02 22:00:08
***************
*** 341,346 ****
--- 341,347 ----
      array_query = (char *) ecpg_alloc(strlen("select typelem from pg_type where oid=") + 11, stmt->lineno);
      sprintf(array_query, "select typelem from pg_type where oid=%d", type);
      query = PQexec(stmt->connection->connection, array_query);
+     free(array_query);
      if (PQresultStatus(query) == PGRES_TUPLES_OK)
      {
          isarray = atol((char *) PQgetvalue(query, 0, 0));

pgsql-bugs by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: AIX 4.3.1, 7.0.3 build annoyances: C++ comments, make all, macro problem
Next
From: Jukka Honkela
Date:
Subject: Re: vacuum analyze fails with latest cvs version