Memmove only happens when it's non null. There's a comparison to null, but not an assignment. The only way it can be null is from malloc which implies size is zero and there's nothing to copy, or malloc failed. On Linux the oom killer kicks in instead of malloc failing.
On February 5, 2016 3:51:05 AM EST, "李俊良" <
cna...@gmail.com> wrote:
>i found a problem in treadstone.cc of file, if NULL assign m_binary,
>how to
>perform a function memmove?
>
>treadstone_transformer :: treadstone_transformer(const unsigned char*
>binary
>, size_t binary_sz)
> : m_binary()
> , m_binary_sz()
> , m_binary_cap()
> , m_error(false)
>{
>m_binary = reinterpret_cast<unsigned char*>(malloc(sizeof(unsigned char
>*) * binary_sz));
> m_binary_sz = binary_sz;
> m_binary_cap = binary_sz;
> m_error = m_binary == NULL;
>
> if (m_binary)
> {
> memmove(m_binary, binary, binary_sz);
> }
>}
--
Sent from my phone. Please excuse my brevity.