Mercurial > cpython-lru_cache-weakref
diff PC/_subprocess.c @ 73650:071cc767a28e
Check for PyUnicode_AS_UNICODE() failure
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Mon, 21 Nov 2011 02:01:41 +0100 |
| parents | 8beaa9a37387 |
| children | da608aa6f59e |
line wrap: on
line diff
--- a/PC/_subprocess.c Mon Nov 21 01:17:27 2011 +0100 +++ b/PC/_subprocess.c Mon Nov 21 02:01:41 2011 +0100 @@ -417,6 +417,7 @@ PROCESS_INFORMATION pi; STARTUPINFOW si; PyObject* environment; + wchar_t *wenvironment; Py_UNICODE* application_name; Py_UNICODE* command_line; @@ -461,6 +462,17 @@ 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 @@ NULL, inherit_handles, creation_flags | CREATE_UNICODE_ENVIRONMENT, - environment ? PyUnicode_AS_UNICODE(environment) : NULL, + wenvironment, current_directory, &si, &pi);
