代码工作正常,但是当我在 cppcheck 上检查它时,我发现空指针 dereferenc 错误我无法理解如何解决它。任何想法将不胜感激
这是我收到错误的代码部分
#ifdef DEBUG_LEVEL_MID
std::clog << "STARTING FUNCTION int ConfigurationType::ExecuteMessageType()" << std::endl;
std::clog << "message with code : " << message_to_execute->code << "will be tried o executed" << std::endl;
#endif
if(!message_to_execute)
{
#ifdef DEBUG_LEVEL_ERROR
std::cerr << "message_to_execute is null at: int ConfigurationType::ExecuteMessageType()" << std::endl;
#endif
#ifdef DEBUG_LEVEL_MID
std::clog << "message_to_execute is NULL at int ConfigurationType::ExecuteMessageType()" << std::endl;
std::clog << "ENDING FUNCTION (0): int ConfigurationType::ExecuteMessageType()" << std::endl;
#endif
return 0;
}
错误是:可能的空指针取消引用:message_to_execute - 否则检查它是否为空是多余的。