Skip to content

Commit

Permalink
avoid NULL argument to memcpy()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mflatt committed Aug 12, 2014
1 parent 3c8b5b6 commit df375da
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions racket/src/racket/sgc/sgc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit df375da

Please sign in to comment.