Re: BUG #17816: Invalid memory access in translate function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #17816: Invalid memory access in translate function
Дата
Msg-id 1399976.1677685570@sss.pgh.pa.us
обсуждение исходный текст
Ответ на BUG #17816: Invalid memory access in translate function  (PG Bug reporting form <noreply@postgresql.org>)
Список pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> When running this query in psql with valgrind-enabled server:
> select translate('(123)', '()', '');

> I get:
> ==00:00:00:05.576 29520== Invalid read of size 1
> ==00:00:00:05.576 29520==    at 0x7605BE: pg_utf_mblen (wchar.c:553)
> ==00:00:00:05.576 29520==    by 0x71CEDE: pg_mblen (mbutils.c:968)
> ==00:00:00:05.576 29520==    by 0x67B1E3: translate (oracle_compat.c:864)

Thanks for the report!

> These changes fix the issue:
> for (i = 0; i < from_index; i++)
> {
>     if (p >= (to_ptr + tolen))
>         break;
>     p += pg_mblen(p);
> }

Yeah, I agree, we need to switch the order of those two statements.
Will fix.

(Might be worth pulling out the common subexpression here?
I wonder if all compilers are smart enough to evaluate to_ptr + to_len
just once.)

            regards, tom lane



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #17812: LOCK TABLE IN ACCESS EXCLUSIVE MODE with a view returns an empty tuple set
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #17812: LOCK TABLE IN ACCESS EXCLUSIVE MODE with a view returns an empty tuple set