Problem with setlocale (found in libecpg) [accessing a memory location after freeing it]

Поиск
Список
Период
Сортировка
От Christof Petig
Тема Problem with setlocale (found in libecpg) [accessing a memory location after freeing it]
Дата
Msg-id 3BAEDE51.EB229159@petig-baender.de
обсуждение исходный текст
Ответы Re: Problem with setlocale (found in libecpg) [accessing a  (Bruce Momjian <pgman@candle.pha.pa.us>)
Re: Problem with setlocale (found in libecpg) [accessing a memory location after freeing it]  (Michael Meskes <meskes@postgresql.org>)
Список pgsql-patches
Hello,

well at first I could not believe what I was seeing ...

Look at the following code (ecpg/lib/execute.c):

   const char *locale=setlocale(LC_NUMERIC, NULL);
   setlocale(LC_NUMERIC, "C");
[....]
   setlocale(LC_NUMERIC, locale);


Well at least on glibc-2.2 it seems that setlocale retuns a pointer to
malloced memory, and frees this pointer on subsequent calls to
setlocale. This is standard conformant and has good reasons. But used as
above it is lethal (but not lethal enough to be easily recognized). So
the content locale points to is freed by the second call to setlocale.

The remedy is easy (given that _no other_ call to setlocale happens
inbetween ...)

   const char *locale=setlocale(LC_NUMERIC, "C");
   [...]
   setlocale(LC_NUMERIC, locale);


So I would kindly ask you to take a second look at every invokation of
setlocale. And to apply the following patch.

Yours
    Christof


Вложения

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

Предыдущее
От: Gerhard Häring
Дата:
Сообщение: Re: Makefiles for building with mingw32 on win32
Следующее
От: Justin Clift
Дата:
Сообщение: Re: Makefiles for building with mingw32 on win32