so can someone explain me why this implementation does not perform a null check on _Left before calling CompareTo() method
Because whoever wrote it neglected to check for nulls.
Is there probably some flaw in usage which leads to such an unpredictable behavior?
Well, comparing a null pointer to something is probably an edge case, but I certainly wouldn't call it a "flaw". The implementation of ==
is incorrect.
To workaround this issue, you could reverse your equality check and/or check for null
:
if (unitNames[i] == nullptr)
dwRet = BUMC_NOT_COMPLETE;