[LLVMbugs] [Bug 22263] New: null ptr deref warning after call to non returning function

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jan 19 11:13:14 PST 2015


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

            Bug ID: 22263
           Summary: null ptr deref warning after call to non returning
                    function
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: nick at mozilla.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 13702
  --> http://llvm.org/bugs/attachment.cgi?id=13702&action=edit
results of running scan build

Using checker-276, we have code that basically handles our own memory
allocations [0], something like [1]:

void * my_malloc (size_t sz) {
  void * p = malloc(sz);
  if (p == NULL) {
    fprintf(stderr, "out of memeory");
    abort();
  }
}

Now, throughout our code we have instances where we get warnings about null
pointer derefs right after calling this function [2].

ex:

somevar = my_malloc(some_size);
somevar->member;

And we'll get a warning about a possible pointer dereference from the second
statement.  This isn't right, because the allocation function checks if null
then aborts the process.

Please see [3] and [4] for more info.  Thanks!

[0]
https://github.com/h2o/h2o/blob/35707d051e30a3a986b66eb317e2c711b221795c/include/h2o/memory.h#L243-L249
[1]
https://github.com/h2o/h2o/blob/9cb45394b00f3ca9644ca99ca3d28f96a089835a/lib/common/memory.c#L57-L61
[2]
https://github.com/h2o/h2o/blob/9cb45394b00f3ca9644ca99ca3d28f96a089835a/lib/handler/configurator/expires.c#L63-L65
[3] https://github.com/h2o/h2o/issues/107
[4] https://github.com/h2o/h2o/pull/108#issuecomment-70044354

-- 
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/20150119/ac41f1c3/attachment.html>


More information about the llvm-bugs mailing list