Fix undefined behavior while calling memcpy

Calling memcpy(x, 0, 0) is technically undefined (although it should usually
be a no-op).