avoid NULL argument to memcpy()

gcc 4.9 takes advantage of the specification of undefined behavior if
you pass a NULL to memcpy(), even if the last argument is 0
This commit is contained in:
Matthew Flatt 2014-08-12 08:47:14 +01:00
parent 3c8b5b672e
commit df375daef4

View File

@ -1653,11 +1653,11 @@ void GC_add_roots(void *start, void *end)
mem_real_use += (sizeof(uintptr_t) * roots_size);
memcpy((void *)naya, (void *)roots,
sizeof(uintptr_t) * roots_count);
if (roots)
if (roots) {
memcpy((void *)naya, (void *)roots,
sizeof(uintptr_t) * roots_count);
free_managed(roots);
}
roots = naya;
}