Re: Text search segmentation fault

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: Text search segmentation fault
Дата
Msg-id 87k58ep0uq.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Re: Text search segmentation fault  (Teodor Sigaev <teodor@sigaev.ru>)
Ответы Re: Text search segmentation fault
Re: Text search segmentation fault
Список pgsql-general
Teodor Sigaev <teodor@sigaev.ru> writes:

> I reproduced the bug with a help of Grzegorz's point for 64-bit box. So, patch
> is attached and I'm going to commit it
...

> !     Conf->flagval[(unsigned int) *s] = (unsigned char) val;
...
> !     Conf->flagval[*(unsigned char*) s] = (unsigned char) val;

Maybe I'm missing something but I don't understand how this fixes the problem.
s is a "char*" so type punning it to an unsigned char * before dereferencing
it is really the same as casting it to unsigned char directly and casting it
to unsigned int really ought to have done the same thing anyways.

All of the changes are of this type so I can't see how your patch could have
fixed the problem.

And in general casting the pointer before dereferencing it is a whole lot
scarier code which should raise eyebrows a lot faster than just a simple cast
to unsigned char like you had it originally.

What really boggles me is why you don't just use unsigned chars everywhere and
remove all of these casts. or would that just move the casts to strcmp and
company?

--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com
  Ask me about EnterpriseDB's Slony Replication support!

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

Предыдущее
От: Richard Broersma
Дата:
Сообщение: Re: Pet Peeves?
Следующее
От: Teodor Sigaev
Дата:
Сообщение: Re: Text search segmentation fault