From: Martin Ling Date: Sat, 30 Aug 2014 11:16:51 +0000 (+0100) Subject: C++: Add sanity checks in StructureWrapper. X-Git-Tag: libsigrok-0.4.0~1063 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=78132e2a138f707b9522c41110079f92b39afc88;p=libsigrok.git C++: Add sanity checks in StructureWrapper. --- 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(); }