]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Patch #1093585: raise a ValueError for negative history items in
authorMartin v. Löwis <martin@v.loewis.de>
Sun, 27 Feb 2005 20:34:01 +0000 (20:34 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Sun, 27 Feb 2005 20:34:01 +0000 (20:34 +0000)
remove_history and replace_history.

Misc/NEWS
Modules/readline.c

index 9106f80d9291e6e5a4638283aaa1b7beaf903785..055c32b3770a091a00e104cb723ebf6624895e2b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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
 -----
 
index 9d5a6bec6e1adff411fb370832a650b01a228a9e..706eb7a10e753933f358fa3e2010e505c0357844 100644 (file)
@@ -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,