Fix memcpy crashing on android due to wrong malloc