https://llvm.org/bugs/show_bug.cgi?id=27674

            Bug ID: 27674
           Summary: Multiple if / else if checks for NULL result in
                    incorrect reporting of NULL dereference in final else
           Product: clang
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kreme...@apple.com
          Reporter: mark.rog...@powermapper.com
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

$ clang --version
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

Reproduction code:

class Buffer
{
    void* m_pBuffer;
    size_t m_size;

    bool Equal( const Buffer& rhs)
    {
        if( !m_pBuffer && rhs.m_pBuffer )
        {
            // m_pBuffer is null
            return false;
        }
        else if( m_pBuffer && !rhs.m_pBuffer )
        {
            // rhs.m_pBuffer is null
            return false;
        }
        else
        {
            // neither argument is null but analyzer warns:
            // Null pointer argument in call to memory comparison functions
            int cmp = memcmp( m_pBuffer, rhs.m_pBuffer, std::min( m_size,
rhs.m_size ) );
            return cmp == 0;
        }
    }
};

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to