Hello,
it seems we got a false positive on C++ rule “Null pointers should not be dereferenced[cpp:S2259]”.
We are using SonarQube 10.0.0.68432.
This issue is raised on this code:
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CString strKey;
strKey.Format(_T("%s"), bstrKey);
if (!m_pMapPairs)
AfxThrowOleDispatchException(-1, _T("No map set for this CaptureBarcode object."));
CString strValue;
if (m_pMapPairs->Lookup(strKey, strValue))
return TRUE;
else
return FALSE;
The issue is reported for the access to m_pMapPairs, although this is already checked for null in:
if (!m_pMapPairs)
AfxThrowOleDispatchException(-1, _T("No map set for this CaptureBarcode object."));
So when really null then this dereferencing code is never reached.
Is this a known issue? Would checking (m_pMapPairs == nullptr) instead of (!m_pMapPairs) fix this false positive? What further information can we provide?
Thanks!