Browse Source

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'.
Mansour Moufid 12 years ago
parent
commit
1ba90ab655
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/common/OpenBSD_malloc_Linux.c

+ 1 - 1
src/common/OpenBSD_malloc_Linux.c

@@ -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)