util: fix use-after-free in UtilSignal/DisconnectSelfInHandler test case

refs #2523

Change-Id: I24e4ae6684ad5450f62cede48739b47cf57ad2b0
diff --git a/tests/unit-tests/util/signal.t.cpp b/tests/unit-tests/util/signal.t.cpp
index df137fe..e975cc2 100644
--- a/tests/unit-tests/util/signal.t.cpp
+++ b/tests/unit-tests/util/signal.t.cpp
@@ -381,14 +381,14 @@
   int hit = 0;
   Connection connection;
   BOOST_CHECK_EQUAL(connection.isConnected(), false);
-  connection = so.sig.connect(bind([&] (SignalOwner0& so) {
+  connection = so.sig.connect(bind([] (int& hit, SignalOwner0& so, Connection& connection) {
     ++hit;
     BOOST_CHECK_EQUAL(connection.isConnected(), true);
     connection.disconnect();
     BOOST_CHECK_EQUAL(connection.isConnected(), false);
     BOOST_CHECK_EQUAL(so.isSigEmpty(), false); // disconnecting hasn't taken effect
-  }, ref(so)));
-  // Bug 2302: 'so' needs to be bound to the handler;
+  }, ref(hit), ref(so), ref(connection)));
+  // Bug 2302, 2523: variables needs to be bound to the handler;
   // lambda capture won't work because closure would be destructed at .disconnect
 
   so.emitSignal(sig);