Re: Problem with setlocale (found in libecpg) [accessing a

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Christof Petig <christof(at)petig-baender(dot)de>
Cc: Michael Meskes <meskes(at)postgresql(dot)org>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Problem with setlocale (found in libecpg) [accessing a
Date: 2001-09-26 20:22:06
Message-ID: 200109262022.f8QKM7K01840@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


Your patch has been added to the PostgreSQL unapplied patches list at:

http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

> 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
>

[ application/x-gzip is not supported, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vince Vielhaber 2001-09-26 20:30:52 casting for dates
Previous Message Tom Lane 2001-09-26 20:05:44 Re: Spinlock performance improvement proposal

Browse pgsql-patches by date

  From Date Subject
Next Message greg 2001-09-26 23:42:09 How to diff a man page?
Previous Message Bruce Momjian 2001-09-26 19:58:11 Re: Patch for pl/tcl Tcl_ExternalToUtf and Tcl_UtfToExternal