diff options
| author | Martin v. Löwis <martin@v.loewis.de> | 2005-02-27 20:33:25 +0000 |
|---|---|---|
| committer | Martin v. Löwis <martin@v.loewis.de> | 2005-02-27 20:33:25 +0000 |
| commit | 528b559cafb28cb18cda2ec97cb97359bdfe4ee4 (patch) | |
| tree | 43ebdde04f5d33c3a4abb67247abc7a61454cc51 /Modules/readline.c | |
| parent | 77d2a3a8fc6306e7891ce9f4df8da84792f25fab (diff) | |
| download | cpython-528b559cafb28cb18cda2ec97cb97359bdfe4ee4.tar.gz | |
Patch #1093585: raise a ValueError for negative history items in
remove_history and replace_history. Will backport to 2.4.
Diffstat (limited to 'Modules/readline.c')
| -rw-r--r-- | Modules/readline.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Modules/readline.c b/Modules/readline.c index 9d5a6bec6e..706eb7a10e 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -303,6 +303,11 @@ py_remove_history(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i:remove_history", &entry_number)) return NULL; + if (entry_number < 0) { + PyErr_SetString(PyExc_ValueError, + "History index cannot be negative"); + return NULL; + } entry = remove_history(entry_number); if (!entry) { PyErr_Format(PyExc_ValueError, @@ -335,6 +340,11 @@ py_replace_history(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "is:replace_history", &entry_number, &line)) { return NULL; } + if (entry_number < 0) { + PyErr_SetString(PyExc_ValueError, + "History index cannot be negative"); + return NULL; + } old_entry = replace_history_entry(entry_number, line, (void *)NULL); if (!old_entry) { PyErr_Format(PyExc_ValueError, |
