Closed jcurl closed 7 years ago
Thanks for another good report @jcurl. There are two separate problems here, handled by two different rules.
m_LocalConfig.DefaultDir
, or the condition is always true.m_LocalConfig
is a field, so could have been assigned a value in another method. We are going to improve it in the future, so more cases like that are also caught, especially for private fields, where we can make more assumptions.Thanks. It helped me uncover a real problem in any case.
Description
In the provided code snippet, the line highlighted shows S2589 which is wrong (it can be null). The problem is actually earlier where we use
m_LocalConfig
and it can be null.Repro steps
Expected behavior
Expect that the possible use of a null reference is caught instead of assuming it is non-null which results in the false alarm later.
Actual behavior
As described above
Known workarounds
If I fix the real problem, the warning goes away:
Related information