]> granicus.if.org Git - python/commitdiff
bpo-37316: mmap.mmap() passes the wrong variable to PySys_Audit() (GH-14152)
authorZackery Spytz <zspytz@gmail.com>
Fri, 21 Jun 2019 15:31:59 +0000 (09:31 -0600)
committerSteve Dower <steve.dower@python.org>
Fri, 21 Jun 2019 15:31:59 +0000 (08:31 -0700)
Also, add a missing call to va_end() in PySys_Audit().

Lib/test/audit-tests.py
Lib/test/test_audit.py
Misc/NEWS.d/next/Core and Builtins/2019-06-17-03-53-16.bpo-37316.LytDX_.rst [new file with mode: 0644]
Modules/mmapmodule.c
Python/sysmodule.c

index 7a7725f7c212cc5e357afa1d87673a3d95c57d3a..ddeff22030a4b26f242ce8b48c2ca126f5d10d2b 100644 (file)
@@ -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)
index f629b7b3d073cc8b7b489728442d5bef99823b9b..2fc41bddcb8aea52b657618a36c764f63c2bb6d0 100644 (file)
@@ -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 (file)
index 0000000..40436d4
--- /dev/null
@@ -0,0 +1 @@
+Fix the :c:func:`PySys_Audit` call in :class:`mmap.mmap`.
index 755f1669d8d321b4363c88c8460d344305382dcf..9e3414f94e3124b69de5b633c94b195280a190df 100644 (file)
@@ -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;
     }
 
index 8da839c5a592ecf02c488cc59c7a5a20c3263fb7..d1a6c6a02618149d7b8724d4ec9c95c9a494a682 100644 (file)
@@ -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);