Fix a potentially useless integer overflow check.

GCC 4.2 and maybe other compilers optimize away unsigned integer
overflow checks of the form (foo + bar < foo), for all bar.

Fix one such check in `src/common/OpenBSD_malloc_Linux.c'.
This commit is contained in:
Mansour Moufid 2011-09-19 21:25:23 -04:00 committed by Nick Mathewson
parent ac7b6c508d
commit 1ba90ab655

View file

@ -1236,7 +1236,7 @@ imalloc(size_t size)
ptralloc = 1;
size = malloc_pagesize;
}
if ((size + malloc_pagesize) < size) { /* Check for overflow */
if (size > SIZE_MAX - malloc_pagesize) { /* Check for overflow */
result = NULL;
errno = ENOMEM;
} else if (size <= malloc_maxsize)