mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #6697: Fix a crash if code of "python -c code" contains surrogates
This commit is contained in:
parent
f155f1f4ce
commit
6baded49d0
2 changed files with 26 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue