[vlc-commits] Revert "Internal: Don't throw when wrapping a null	instance"
    Hugo Beauzée-Luyssen 
    git at videolan.org
       
    Mon May 25 10:04:45 CEST 2015
    
    
  
libvlcpp | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed May 20 10:34:06 2015 +0200| [43cab79253a96dbdb71bd3717415405cf8f3a1a8] | committer: Hugo Beauzée-Luyssen
Revert "Internal: Don't throw when wrapping a null instance"
This reverts commit 9d2e6edbbb2e4f1363baff6a745dd4a6e9f48201.
This makes more sense, since most of libvlc_*_release functions will
either assert or assume that the given pointer is non null.
Since shared_ptr will call the deleter for any pointer (including
nullptr), we're better of refusing to wrap a pointer and avoid undefined
behavior
> http://git.videolan.org/gitweb.cgi/libvlcpp.git/?a=commit;h=43cab79253a96dbdb71bd3717415405cf8f3a1a8
---
 vlcpp/Internal.hpp |    2 ++
 1 file changed, 2 insertions(+)
diff --git a/vlcpp/Internal.hpp b/vlcpp/Internal.hpp
index 60412de..1fa3545 100644
--- a/vlcpp/Internal.hpp
+++ b/vlcpp/Internal.hpp
@@ -68,6 +68,8 @@ class Internal
         Internal( InternalPtr obj, Releaser releaser )
             : m_obj{ obj, releaser }
         {
+            if ( obj == nullptr )
+                throw std::runtime_error("Wrapping a NULL instance");
         }
 
         Internal(Releaser releaser)
    
    
More information about the vlc-commits
mailing list