Re: Server Programming in C: palloc() and pfree()

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Server Programming in C: palloc() and pfree()
Дата
Msg-id 5417.1139524324@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Server Programming in C: palloc() and pfree()  (Rodrigo Hjort <rodrigo.hjort@gmail.com>)
Список pgsql-hackers
Rodrigo Hjort <rodrigo.hjort@gmail.com> writes:
> I'm having some problems when using "pfree()" on functions in C.

I think your pfree is just the bearer of bad news, ie, it's the victim
of a memory clobber that you've already executed.  Take another look at
your string manipulation --- that strncpy followed by strcat in
particular looks pretty dangerous, because strncpy doesn't guarantee
a trailing null.

[ looks again... ]  Hmm, not to mention that you are overwriting the
input "str", which is bad enough in itself, but you are doing so with
a string longer than the original.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: PostgreSQL 8.0.6 crash
Следующее
От: "Mark Woodward"
Дата:
Сообщение: Re: PostgreSQL 8.0.6 crash