[Python-checkins] cpython (3.5): Issue #28732: Fix crash in os.spawnv() with no elements in args
steve.dower
python-checkins at python.org
Sat Nov 19 21:42:05 EST 2016
https://hg.python.org/cpython/rev/02f416441def
changeset: 105191:02f416441def
branch: 3.5
parent: 105188:1e49abb03e0f
user: Steve Dower <steve.dower at microsoft.com>
date: Sat Nov 19 18:33:39 2016 -0800
summary:
Issue #28732: Fix crash in os.spawnv() with no elements in args
Prevents crashes in some other posixmodule.c functions
files:
Misc/NEWS | 2 ++
Modules/posixmodule.c | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -121,6 +121,8 @@
Library
-------
+- Issue #28732: Fix crash in os.spawnv() with no elements in args
+
- Issue #28485: Always raise ValueError for negative
compileall.compile_dir(workers=...) parameter, even when multithreading is
unavailable.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5186,6 +5186,16 @@
"spawnv() arg 2 must be a tuple or list");
return NULL;
}
+#ifdef MS_WINDOWS
+ /* Avoid changing behavior in maintenance release, but
+ the previous Windows behavior was to crash, so this
+ is a "compatible" improvement. */
+ if (argc == 0) {
+ PyErr_SetString(PyExc_ValueError,
+ "spawnv() arg 2 cannot be empty");
+ return NULL;
+ }
+#endif
argvlist = PyMem_NEW(char *, argc+1);
if (argvlist == NULL) {
@@ -5207,7 +5217,9 @@
mode = _P_OVERLAY;
Py_BEGIN_ALLOW_THREADS
+ _Py_BEGIN_SUPPRESS_IPH
spawnval = _spawnv(mode, path_char, argvlist);
+ _Py_END_SUPPRESS_IPH
Py_END_ALLOW_THREADS
free_string_array(argvlist, argc);
@@ -5297,7 +5309,9 @@
mode = _P_OVERLAY;
Py_BEGIN_ALLOW_THREADS
+ _Py_BEGIN_SUPPRESS_IPH
spawnval = _spawnve(mode, path_char, argvlist, envlist);
+ _Py_END_SUPPRESS_IPH
Py_END_ALLOW_THREADS
if (spawnval == -1)
@@ -7022,7 +7036,9 @@
do {
Py_BEGIN_ALLOW_THREADS
+ _Py_BEGIN_SUPPRESS_IPH
res = _cwait(&status, pid, options);
+ _Py_END_SUPPRESS_IPH
Py_END_ALLOW_THREADS
} while (res < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
if (res < 0)
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list