Re: Unlikely-to-happen crash in ecpg driver caused by NULL-pointer check not done

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: Unlikely-to-happen crash in ecpg driver caused by NULL-pointer check not done
Дата
Msg-id CAB7nPqS-oWUbRjPwzFm9WtEK0j-6pVvHT=hTErBh56tDdn=-rQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Unlikely-to-happen crash in ecpg driver caused by NULL-pointer check not done  (Heikki Linnakangas <hlinnakangas@vmware.com>)
Ответы Re: Unlikely-to-happen crash in ecpg driver caused by NULL-pointer check not done  (Michael Meskes <meskes@postgresql.org>)
Список pgsql-hackers
On Tue, Feb 3, 2015 at 7:50 PM, Heikki Linnakangas
<hlinnakangas@vmware.com> wrote:
> Hmm. Since the ecpg_add_mem call is done after setting (*(void **) var),
> that's left to point to already-free'd memory. The other call sites have a
> similar issue. I haven't analyzed the code to check if that's harmless or
> not, but seems better to not do that.
Right, it is an error do allocate this memory if there is a risk that
it may be freed. Hence fixed.

> In ecpg_add_mem, the ecpg_raise() call is unnecessary, since ecpg_alloc
> already does that on failure.
Right, check.

> (It would be less error-prone to have an ecpg_alloc_auto() function that
> combines ecpg_alloc+ecpg_add_mem in one call.)
It makes sense.

>> /* Here are some methods used by the lib. */
>>
>> /* Returns a pointer to a string containing a simple type name. */

> That second comment is completely bogus. It's not this patch's fault, it's
> been like that forever, but just happened to notice..
Corrected.

All those things are addressed in the patch attached.
--
Michael

Вложения

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

Предыдущее
От: Petr Jelinek
Дата:
Сообщение: Re: Getting rid of wal_level=archive and default to hot_standby + wal_senders
Следующее
От: Kevin Grittner
Дата:
Сообщение: Re: Release note bloat is getting out of hand