mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
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:
committed by
Nick Mathewson
parent
ac7b6c508d
commit
1ba90ab655
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user