diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-11-21 01:01:41 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-11-21 01:01:41 (GMT) |
commit | 333544764619b8e338b7485ea94b9be9b9e75a9d (patch) | |
tree | da0738d3cce74dbc11379c145097277d0fd9ddb6 /PC/_subprocess.c | |
parent | 53b33e767d9aa85f2bf3add5850499596f9d0558 (diff) | |
download | cpython-333544764619b8e338b7485ea94b9be9b9e75a9d.zip cpython-333544764619b8e338b7485ea94b9be9b9e75a9d.tar.gz cpython-333544764619b8e338b7485ea94b9be9b9e75a9d.tar.bz2 |
Check for PyUnicode_AS_UNICODE() failure
Diffstat (limited to 'PC/_subprocess.c')
-rw-r--r-- | PC/_subprocess.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/PC/_subprocess.c b/PC/_subprocess.c index f0ad559..ec93d25 100644 --- a/PC/_subprocess.c +++ b/PC/_subprocess.c @@ -417,6 +417,7 @@ sp_CreateProcess(PyObject* self, PyObject* args) PROCESS_INFORMATION pi; STARTUPINFOW si; PyObject* environment; + wchar_t *wenvironment; Py_UNICODE* application_name; Py_UNICODE* command_line; @@ -461,6 +462,17 @@ sp_CreateProcess(PyObject* self, PyObject* args) return NULL; } + if (environment) { + wenvironment = PyUnicode_AsUnicode(environment) + if (wenvironment == NULL) + { + Py_XDECREF(environment); + return NULL; + } + } + else + wenvironment = NULL; + Py_BEGIN_ALLOW_THREADS result = CreateProcessW(application_name, command_line, @@ -468,7 +480,7 @@ sp_CreateProcess(PyObject* self, PyObject* args) NULL, inherit_handles, creation_flags | CREATE_UNICODE_ENVIRONMENT, - environment ? PyUnicode_AS_UNICODE(environment) : NULL, + wenvironment, current_directory, &si, &pi); |