Skip site navigation (1) Skip section navigation (2)

Re: libpd - PQfinish() - crashes client application in some cases

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jean-Michel(dot)chabanne" <jeanmichel(dot)chabanne(at)free(dot)fr>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: libpd - PQfinish() - crashes client application in some cases
Date: 2001-09-16 21:53:02
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
"Jean-Michel.chabanne" <jeanmichel(dot)chabanne(at)free(dot)fr> writes:
> ... a first call to PQfinish(...) disconnects the client,
> [ PQstatus returns 'CONNECTION_BAD' ], and A SECOND call to PQfinish(..)
> make the client to crash with a system message 'segmentation fault'.

Freeing the same chunk of memory twice leads to a crash in most
implementations of malloc/free :-(.  I don't think that libpq can be
expected to protect you from this.  Don't PQfinish() the same connection
object more than once, because after the first one it's not a connection
object anymore --- only a dangling pointer to freed memory.  For that
matter, you shouldn't call PQstatus() or any other libpq function using
an already-PQfinished connection pointer.

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: John SummerfieldDate: 2001-09-17 04:23:34
Subject: Re: SQLCODE==-209
Previous:From: Tom LaneDate: 2001-09-16 21:48:14
Subject: Re: dynamic-static date once again

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group