Fix dangling pointer
Fix undefined memcpy() behavior