]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python:tests: Fix crashing pymessaging tests
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 13 Nov 2023 23:34:01 +0000 (12:34 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 15 Nov 2023 22:07:36 +0000 (22:07 +0000)
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 <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/messaging.py

index 7a4aa17b9d5de3512646d4c1571034c891528907..c772db08041d43a32e914419fef4c4dcd08874ea 100644 (file)
@@ -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()