mirror of
https://github.com/python/cpython.git
synced 2024-11-27 11:55:13 +08:00
Bernard Herzog pointed out that rl_parse_and_bind modifies its
argument string (bad function!), so we make a temporary copy.
This commit is contained in:
parent
8c2da61811
commit
3b5330ef2d
@ -48,10 +48,17 @@ parse_and_bind(self, args)
|
||||
PyObject *self;
|
||||
PyObject *args;
|
||||
{
|
||||
char *s;
|
||||
char *s, *copy;
|
||||
if (!PyArg_ParseTuple(args, "s", &s))
|
||||
return NULL;
|
||||
rl_parse_and_bind(s);
|
||||
/* Make a copy -- rl_parse_and_bind() modifies its argument */
|
||||
/* Bernard Herzog */
|
||||
copy = malloc(1 + strlen(s));
|
||||
if (copy == NULL)
|
||||
return PyErr_NoMemory();
|
||||
strcpy(copy, s);
|
||||
rl_parse_and_bind(copy);
|
||||
free(copy); /* Free the copy */
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user