summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-17 01:13:37 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-17 01:13:37 (GMT)
commit6baded49d0abf07f141dae489c6a010af1b1e209 (patch)
tree49ec83c86cb48d362b662dbe99b5cd3d2b762027 /Modules
parentf155f1f4cef42e26809e3512634e4ed083b7965c (diff)
downloadcpython-6baded49d0abf07f141dae489c6a010af1b1e209.zip
cpython-6baded49d0abf07f141dae489c6a010af1b1e209.tar.gz
cpython-6baded49d0abf07f141dae489c6a010af1b1e209.tar.bz2
Issue #6697: Fix a crash if code of "python -c code" contains surrogates
Diffstat (limited to 'Modules')
-rw-r--r--Modules/main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 32139f6..92b971f 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -563,18 +563,22 @@ Py_Main(int argc, wchar_t **argv)
}
if (command) {
+ char *commandStr;
PyObject *commandObj = PyUnicode_FromWideChar(
command, wcslen(command));
free(command);
- if (commandObj != NULL) {
- sts = PyRun_SimpleStringFlags(
- _PyUnicode_AsString(commandObj), &cf) != 0;
+ if (commandObj != NULL)
+ commandStr = _PyUnicode_AsString(commandObj);
+ else
+ commandStr = NULL;
+ if (commandStr != NULL) {
+ sts = PyRun_SimpleStringFlags(commandStr, &cf) != 0;
+ Py_DECREF(commandObj);
}
else {
PyErr_Print();
sts = 1;
}
- Py_DECREF(commandObj);
} else if (module) {
sts = RunModule(module, 1);
}