[LLVMbugs] [Bug 23650] New: raw_ostream calls memcpy() with NULL destination in unbuffered mode

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon May 25 09:15:49 PDT 2015


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

            Bug ID: 23650
           Summary: raw_ostream calls memcpy() with NULL destination in
                    unbuffered mode
           Product: libraries
           Version: 3.6
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Support Libraries
          Assignee: unassignedbugs at nondot.org
          Reporter: andrey.vihrov at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Using LLVM 3.6 and compiling with GCC 5.1 with UndefinedBehaviorSanitizer
enabled, this program:

#include <llvm/Support/raw_ostream.h>

int main()
{
    llvm::errs().SetUnbuffered();
    llvm::errs() << "";
}

produces

/usr/include/llvm/Support/raw_ostream.h:171:40: runtime error: null pointer
passed as argument 1, which is declared to never be null

The problematic place is here:
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?view=markup#l168
 In unbuffered mode, OutBufCur is a null pointer, but when Size == 0, the code
still tries to call memcpy() with it.

-- 
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/20150525/35377d3b/attachment.html>


More information about the llvm-bugs mailing list