Fix condition in shm_toc and remove unused function shm_toc_freespace.

Поиск
Список
Период
Сортировка
От Zhang Mingli
Тема Fix condition in shm_toc and remove unused function shm_toc_freespace.
Дата
Msg-id 1c7954e4-1705-4855-a99d-c77bf426c3e7@Spark
обсуждение исходный текст
Ответы Re: Fix condition in shm_toc and remove unused function shm_toc_freespace.  (Zhang Mingli <zmlpostgres@gmail.com>)
Список pgsql-hackers
Hi, hackers

Some conditions in shm_toc_insert and shm_toc_allocate are bogus, like:

if (toc_bytes + nbytes > total_bytes || toc_bytes + nbytes < toc_bytes)

Remove the condition `toc_bytes + nbytes < toc_bytes` and take a sizeof(shm_entry) into account in shm_toc_allocate though 
shm_toc_allocate does that too.

/* Check for memory exhaustion and overflow. */
- if (toc_bytes + nbytes > total_bytes || toc_bytes + nbytes < toc_bytes)
+ if (toc_bytes + sizeof(shm_toc_entry) + nbytes > total_bytes)
{
  SpinLockRelease(&toc->toc_mutex);

shm_toc_freespace is introduced with shm_toc by original commit 6ddd5137b2, but is not used since then, so remove it.


Regards,
Zhang Mingli
Вложения

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

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: recovery modules
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Common function for percent placeholder replacement