Merge branch 'maint'

* maint:
  compat: helper for detecting unsigned overflow
This commit is contained in:
Junio C Hamano
2011-02-10 14:45:55 -08:00
4 changed files with 11 additions and 4 deletions

View File

@ -53,7 +53,7 @@ void *xmalloc(size_t size)
void *xmallocz(size_t size)
{
void *ret;
if (size + 1 < size)
if (unsigned_add_overflows(size, 1))
die("Data too large to fit into virtual memory space.");
ret = xmalloc(size + 1);
((char*)ret)[size] = 0;