From: Uwe Hermann Date: Mon, 24 Nov 2014 00:11:17 +0000 (+0100) Subject: bindings: Session::set_trigger(): Fix segfault condition. X-Git-Tag: libsigrok-0.4.0~711 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e835e8080b6278137ea90f3b10e5d8bc51136a91;p=libsigrok.git bindings: Session::set_trigger(): Fix segfault condition. sr_session_trigger_set(sess, NULL) is a valid thing to do, meaning that any trigger shall be removed from the session. This closes bugs #491 and #496. --- diff --git a/bindings/cxx/classes.cpp b/bindings/cxx/classes.cpp index da21086c..efb4995d 100644 --- a/bindings/cxx/classes.cpp +++ b/bindings/cxx/classes.cpp @@ -1138,7 +1138,11 @@ shared_ptr Session::trigger() void Session::set_trigger(shared_ptr trigger) { - check(sr_session_trigger_set(_structure, trigger->_structure)); + if (!trigger) + // Set NULL trigger, i.e. remove any trigger from the session. + check(sr_session_trigger_set(_structure, NULL)); + else + check(sr_session_trigger_set(_structure, trigger->_structure)); _trigger = trigger; }