[llvm-bugs] [Bug 44203] New: False positive warning "Use of memory after it is freed"

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Dec 2 05:06:02 PST 2019


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

            Bug ID: 44203
           Summary: False positive warning "Use of memory after it is
                    freed"
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: ynezz at true.cz
                CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org

Steps to reproduce:

 git clone git://git.openwrt.org/project/libnl-tiny.git && cd libnl-tiny
 git revert 7ce813fcd66
 mkdir build && cd build && scan-build-10 cmake .. && scan-build-10 make
-j$(nproc)

Copy pasting commit message from commit 7ce813fcd66 which fixes/silence this
warning:

    scan-build from clang version 9 complains about following:

     nl.c:507:9: warning: Use of memory after it is freed
            while (nlmsg_ok(hdr, n)) {
                   ^~~~~~~~~~~~~~~~

    which seems to be impossible codepath as clang analyzer doesn't somehow
    account properly nl_syserr2nlerr(errno) return value:

     } else {
        free(msg.msg_control);
        free(*buf);
        return -nl_syserr2nlerr(errno);
     }

    which should be always < 0, but analyzer is still checking for > 0 code
    path as well for some reason. So in order to make the analyzer happy,
    set the buf pointer to NULL explicitly and add assert to make it clear,
    that this codepath should never happen.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191202/50b9eb29/attachment.html>


More information about the llvm-bugs mailing list