summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-12-04 15:34:39 (GMT)
committerGuido van Rossum <guido@python.org>1998-12-04 15:34:39 (GMT)
commit3b5330ef2d9b6c19ac18e7630059d90e4f5ab991 (patch)
tree8ca2d4c3c621fa60875191a7a8faaaccb028ac1d /Modules
parent8c2da61811e3f6aa50859d656b7c2f0ac58226f3 (diff)
downloadcpython-3b5330ef2d9b6c19ac18e7630059d90e4f5ab991.zip
cpython-3b5330ef2d9b6c19ac18e7630059d90e4f5ab991.tar.gz
cpython-3b5330ef2d9b6c19ac18e7630059d90e4f5ab991.tar.bz2
Bernard Herzog pointed out that rl_parse_and_bind modifies its
argument string (bad function!), so we make a temporary copy.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/readline.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Modules/readline.c b/Modules/readline.c
index 899a223..915cc4a 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -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;
}