if (NULL == m_buffer)
makes sure m_buffer
is NULL
, and then you derefence it with
std::cout << "Thread : " << m_buffer->m_id << "......work buffer is null" << std::endl;
^^^^^^^^^^^^^^^
this, which is only legal if m_buffer
is not NULL
(more precisely, only if it points to a correctly constructed WorkBuffer
).
If NULL
is a possible input for your function, you need to check for it before the very first dereference and then either make it point to something valid or leave the function without dereferencing.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…