[LLVMbugs] [Bug 15623] New: False positive when checking pointers for NULL without using != NULL

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Mar 29 00:52:11 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=15623

            Bug ID: 15623
           Summary: False positive when checking pointers for NULL without
                    using != NULL
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: daniel at fahlgren.se
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Clang gives a false positive on the following example:

#include <string.h>
#include <stdlib.h>
#include <stdbool.h>

bool foo(void) {
   char *param = malloc(10);
   char *value = malloc(10);
   bool ok = (param && value);
   free(param);
   free(value);
   return ok;
}


test.c:11:4: warning: Use of memory after it is freed
   return ok;
   ^      ~~
1 warning generated.

The warning is removed if the check is changed to:

   bool ok = (param != NULL && value != NULL);

-- 
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/20130329/d37c3eea/attachment.html>


More information about the llvm-bugs mailing list