From 3c3f6be0c8b8d6b38e219652580e2edef0f0a757 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 13 Nov 2013 02:48:20 +0000 Subject: Fix a null pointer dereference when copying a null polymorphic pointer. This bug only bit the C++98 build bots because all of the actual uses really do move. ;] But not *quite* ready to do the whole C++11 switch yet, so clean it up. Also add a unit test that catches this immediately. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194548 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/polymorphic_ptr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/llvm') diff --git a/include/llvm/ADT/polymorphic_ptr.h b/include/llvm/ADT/polymorphic_ptr.h index a168747..b8d8d71 100644 --- a/include/llvm/ADT/polymorphic_ptr.h +++ b/include/llvm/ADT/polymorphic_ptr.h @@ -39,7 +39,7 @@ template class polymorphic_ptr { public: polymorphic_ptr(T *ptr = 0) : ptr(ptr) {} - polymorphic_ptr(const polymorphic_ptr &arg) : ptr(arg->clone()) {} + polymorphic_ptr(const polymorphic_ptr &arg) : ptr(arg ? arg->clone() : 0) {} #if LLVM_HAS_RVALUE_REFERENCES polymorphic_ptr(polymorphic_ptr &&arg) : ptr(arg.take()) {} #endif -- cgit v1.1