summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2019-06-21 15:31:59 (GMT)
committerSteve Dower <steve.dower@python.org>2019-06-21 15:31:59 (GMT)
commit08286d52b29de604a4b187bf1f0d4209e39c926c (patch)
tree36af2d00c327f0482135deac89d724481ce2ee76
parent08970cb03c61f62f4f69e7769d0075fa66bb86aa (diff)
downloadcpython-08286d52b29de604a4b187bf1f0d4209e39c926c.zip
cpython-08286d52b29de604a4b187bf1f0d4209e39c926c.tar.gz
cpython-08286d52b29de604a4b187bf1f0d4209e39c926c.tar.bz2
bpo-37316: mmap.mmap() passes the wrong variable to PySys_Audit() (GH-14152)
Also, add a missing call to va_end() in PySys_Audit().
-rw-r--r--Lib/test/audit-tests.py7
-rw-r--r--Lib/test/test_audit.py3
-rw-r--r--Misc/NEWS.d/next/Core and Builtins/2019-06-17-03-53-16.bpo-37316.LytDX_.rst1
-rw-r--r--Modules/mmapmodule.c2
-rw-r--r--Python/sysmodule.c1
5 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/audit-tests.py b/Lib/test/audit-tests.py
index 7a7725f..ddeff22 100644
--- a/Lib/test/audit-tests.py
+++ b/Lib/test/audit-tests.py
@@ -261,6 +261,13 @@ def test_cantrace():
assertSequenceEqual(["call"] * 4, traced)
+def test_mmap():
+ import mmap
+ with TestHook() as hook:
+ mmap.mmap(-1, 8)
+ assertEqual(hook.seen[0][1][:2], (-1, 8))
+
+
if __name__ == "__main__":
from test.libregrtest.setup import suppress_msvcrt_asserts
suppress_msvcrt_asserts(False)
diff --git a/Lib/test/test_audit.py b/Lib/test/test_audit.py
index f629b7b..2fc41bd 100644
--- a/Lib/test/test_audit.py
+++ b/Lib/test/test_audit.py
@@ -74,6 +74,9 @@ class AuditTest(unittest.TestCase):
def test_cantrace(self):
self.do_test("test_cantrace")
+ def test_mmap(self):
+ self.do_test("test_mmap")
+
if __name__ == "__main__":
unittest.main()
diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-06-17-03-53-16.bpo-37316.LytDX_.rst b/Misc/NEWS.d/next/Core and Builtins/2019-06-17-03-53-16.bpo-37316.LytDX_.rst
new file mode 100644
index 0000000..40436d4
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2019-06-17-03-53-16.bpo-37316.LytDX_.rst
@@ -0,0 +1 @@
+Fix the :c:func:`PySys_Audit` call in :class:`mmap.mmap`.
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 755f166..9e3414f 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -1154,7 +1154,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
}
if (PySys_Audit("mmap.__new__", "ini" _Py_PARSE_OFF_T,
- fileno, map_size, access, offset) < 0) {
+ fd, map_size, access, offset) < 0) {
return NULL;
}
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 8da839c..d1a6c6a 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -182,6 +182,7 @@ PySys_Audit(const char *event, const char *argFormat, ...)
va_list args;
va_start(args, argFormat);
eventArgs = Py_VaBuildValue(argFormat, args);
+ va_end(args);
if (eventArgs && !PyTuple_Check(eventArgs)) {
PyObject *argTuple = PyTuple_Pack(1, eventArgs);
Py_DECREF(eventArgs);