summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/readline.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/readline.c b/Modules/readline.c
index 35655c7..7d1f703 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -351,6 +351,12 @@ readline_append_history_file_impl(PyObject *module, int nelements,
PyObject *filename_obj)
/*[clinic end generated code: output=5df06fc9da56e4e4 input=784b774db3a4b7c5]*/
{
+ if (nelements < 0)
+ {
+ PyErr_SetString(PyExc_ValueError, "nelements must be positive");
+ return NULL;
+ }
+
PyObject *filename_bytes;
const char *filename;
int err;