diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2005-02-27 20:34:01 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2005-02-27 20:34:01 (GMT) |
commit | ac4c46035c5bf1f1d059159146e7bec9acb76561 (patch) | |
tree | 31b1704e82593bcdc604c4a7e6611833d591e0c2 | |
parent | fa141f3014d3b3c092f4a3f026a52a6374824c12 (diff) | |
download | cpython-ac4c46035c5bf1f1d059159146e7bec9acb76561.zip cpython-ac4c46035c5bf1f1d059159146e7bec9acb76561.tar.gz cpython-ac4c46035c5bf1f1d059159146e7bec9acb76561.tar.bz2 |
Patch #1093585: raise a ValueError for negative history items in
remove_history and replace_history.
-rw-r--r-- | Misc/NEWS | 8 | ||||
-rw-r--r-- | Modules/readline.c | 10 |
2 files changed, 17 insertions, 1 deletions
@@ -25,6 +25,13 @@ Core and builtins is provided. +Extension Modules +----------------- + +- Patch #1093585: raise a ValueError for negative history items in readline. + {remove_history,replace_history} + + Library ------- @@ -59,7 +66,6 @@ Library - Bug #1083110: ``zlib.decompress.flush()`` would segfault if called immediately after creating the object, without any intervening ``.decompress()`` calls. - Build ----- diff --git a/Modules/readline.c b/Modules/readline.c index 9d5a6be..706eb7a 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, |