From beff3e6d7762b423500a7ebf163878ede68b4a2f Mon Sep 17 00:00:00 2001 From: Joseph Sutton Date: Tue, 14 Nov 2023 12:34:01 +1300 Subject: [PATCH] python:tests: Fix crashing pymessaging tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 8c75d9fc73614fad29a998d08c4b11034ab2aebb changed Messaging.deregister() to take a two‐element tuple containing private data as well as a callback, but it did not change the call in samba.tests.messaging.MessagingTests.test_register to match. Since imessaging_deregister() completely ignored the ‘private_data’ parameter passed to it (assuming the callback was registered with msg_type == -1), everything still appeared to work — until commit b22c21799527323877b330c16c23057582721abb changed Messaging.deregister() to no longer leak memory. Now the wrong variable had its reference count decremented, causing the test to crash. Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- python/samba/tests/messaging.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/samba/tests/messaging.py b/python/samba/tests/messaging.py index 7a4aa17b9d5..c772db08041 100644 --- a/python/samba/tests/messaging.py +++ b/python/samba/tests/messaging.py @@ -39,9 +39,10 @@ class MessagingTests(TestCase): def callback(): pass - msg_type = x.register((callback, None)) + callback_and_context = (callback, None) + msg_type = x.register(callback_and_context) self.assertTrue(isinstance(msg_type, int)) - x.deregister(callback, msg_type) + x.deregister(callback_and_context, msg_type) def test_all_servers(self): x = self.get_context()