Re: Server Programming in C: palloc() and pfree() - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: Server Programming in C: palloc() and pfree()
Date
Msg-id 20060209212814.GF14852@svana.org
Whole thread Raw
In response to Server Programming in C: palloc() and pfree()  (Rodrigo Hjort <rodrigo.hjort@gmail.com>)
List pgsql-hackers
On Thu, Feb 09, 2006 at 04:16:51PM -0200, Rodrigo Hjort wrote:
> I'm having some problems when using "pfree()" on functions in C.
> Calling it on "psql" gives the exception below on both versions of function
> "insert()" [1,2] if "pfree()" is enabled:
>
> server closed the connection unexpectedly
>         This probably means the server terminated abnormally
>         before or while processing the request.
> conexão com servidor foi perdida
> (connection to the server was lost)
>
> The strange is that it doesn't happen with the function "delstr()" [3],
> which has "pfree()".
> What could am I doing wrong?

You havn't said how you are calling the functions. For example, did you
declare them as cstring or text? text is not null terminated but a
varlena struct. So if you use text you'll end up with buffer overruns.

Could you provide a complete example with SQL?
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] Sequences/defaults and pg_dump
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Upcoming re-releases