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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to