mirror of
https://github.com/postgres/postgres.git
synced 2025-05-08 07:21:33 +03:00
Another portability fix for tzcode2016g update.
clang points out that SIZE_MAX wouldn't fit into an int, which means this comparison is pretty useless. Per report from Thomas Munro.
This commit is contained in:
parent
9ee22f1ff6
commit
9937088b26
@ -424,9 +424,8 @@ growalloc(void *ptr, size_t itemsize, int nitems, int *nitems_alloc)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
int nitems_max = INT_MAX - WORK_AROUND_QTBUG_53071;
|
int nitems_max = INT_MAX - WORK_AROUND_QTBUG_53071;
|
||||||
int amax = nitems_max < SIZE_MAX ? nitems_max : SIZE_MAX;
|
|
||||||
|
|
||||||
if ((amax - 1) / 3 * 2 < *nitems_alloc)
|
if ((nitems_max - 1) / 3 * 2 < *nitems_alloc)
|
||||||
memory_exhausted(_("int overflow"));
|
memory_exhausted(_("int overflow"));
|
||||||
*nitems_alloc = *nitems_alloc + (*nitems_alloc >> 1) + 1;
|
*nitems_alloc = *nitems_alloc + (*nitems_alloc >> 1) + 1;
|
||||||
return erealloc(ptr, size_product(*nitems_alloc, itemsize));
|
return erealloc(ptr, size_product(*nitems_alloc, itemsize));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user