summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMichael Curran <mick@nvaccess.org>2022-09-26 16:27:44 (GMT)
committerGitHub <noreply@github.com>2022-09-26 16:27:44 (GMT)
commitd79dd929accac13832bc13ed12be34466584ca81 (patch)
tree86094a2086448dd1fc5440c6be39405cff5d68eb /Lib/test
parent85752decbfd733284ffdb8ae9c93b927765236c7 (diff)
downloadcpython-d79dd929accac13832bc13ed12be34466584ca81.zip
cpython-d79dd929accac13832bc13ed12be34466584ca81.tar.gz
cpython-d79dd929accac13832bc13ed12be34466584ca81.tar.bz2
bpo-38748: Add ctypes test for stack corruption due to misaligned arguments (GH-26204)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_ctypes/test_callbacks.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_ctypes/test_callbacks.py b/Lib/test/test_ctypes/test_callbacks.py
index b5bef04..e8fa3e6 100644
--- a/Lib/test/test_ctypes/test_callbacks.py
+++ b/Lib/test/test_ctypes/test_callbacks.py
@@ -1,3 +1,4 @@
+import sys
import functools
import unittest
from test import support
@@ -150,6 +151,18 @@ class Callbacks(unittest.TestCase):
gc.collect()
CFUNCTYPE(None)(lambda x=Nasty(): None)
+ @need_symbol('WINFUNCTYPE')
+ def test_i38748_stackCorruption(self):
+ callback_funcType = WINFUNCTYPE(c_long, c_long, c_longlong)
+ @callback_funcType
+ def callback(a, b):
+ c = a + b
+ print(f"a={a}, b={b}, c={c}")
+ return c
+ dll = cdll[_ctypes_test.__file__]
+ # With no fix for i38748, the next line will raise OSError and cause the test to fail.
+ self.assertEqual(dll._test_i38748_runCallback(callback, 5, 10), 15)
+
@need_symbol('WINFUNCTYPE')
class StdcallCallbacks(Callbacks):