diff --git a/bindings/cxx/include/libsigrok/libsigrok.hpp b/bindings/cxx/include/libsigrok/libsigrok.hpp index e16a9536..8c8b5549 100644 --- a/bindings/cxx/include/libsigrok/libsigrok.hpp +++ b/bindings/cxx/include/libsigrok/libsigrok.hpp @@ -148,6 +148,8 @@ public: shared_ptr > get_shared_pointer(Parent *parent) { + if (!parent) + throw Error(SR_ERR_BUG); this->parent = static_pointer_cast(parent->shared_from_this()); return shared_ptr >( this, reset_parent); @@ -155,6 +157,8 @@ public: shared_ptr > get_shared_pointer(shared_ptr parent) { + if (!parent) + throw Error(SR_ERR_BUG); this->parent = parent; return shared_ptr >( this, reset_parent); @@ -162,6 +166,8 @@ public: protected: static void reset_parent(StructureWrapper *object) { + if (!object->parent) + throw Error(SR_ERR_BUG); object->parent.reset(); }