Greets all,
While attempting to clean up some memory leaks, I have encountered some 
difficulties.  In the code for PQclear() we have the check:

  if (!res)
	return;

The problem arrises when the result object pointer you are passing to clear 
contains not a null and not a valid result object address, but a junk pointer.
PQclear() seg faults when the address is outside of the data segment.
(libpq bug?)
 
My question is, how does one determine when a PGresult* contains the address 
of a valid result object?  Rewriting the calling code is not an option sadly.
What I would like to be able to do is something like this:

	if ( result_is_valid( res ) )
	{
		PQclear( res );
	}

Thanks in advance for any help/suggestions.
  -Wade

Fri, 30 Aug 2002 09:56:58 -0700
wade <wade@wavefire.com>
(libpq) PQclear on questionable result pointer.
wade <wade@wavefire.com> writes:
> The problem arrises when the result object pointer you are passing to clear 
> contains not a null and not a valid result object address, but a junk pointer.
> PQclear() seg faults when the address is outside of the data segment.
> (libpq bug?)

No, that's a bug in *your* code.  Passing a bogus pointer to any library
anywhere will make it segfault, because there's no reasonable way to
verify a pointer.

			regards, tom lane

Fri, 30 Aug 2002 13:01:56 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: (libpq) PQclear on questionable result pointer. 