summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorPeter Bierma <zintensitydev@gmail.com>2024-12-05 16:07:38 (GMT)
committerGitHub <noreply@github.com>2024-12-05 16:07:38 (GMT)
commit208b0fb645c0e14b0826c0014e74a0b70c58c9d6 (patch)
tree2e4f8541c8de96054a8fad7443f8b3e867fac63c /Modules
parent67b9a5331ae45aa126877d7f96a1e235600f9c4b (diff)
downloadcpython-208b0fb645c0e14b0826c0014e74a0b70c58c9d6.zip
cpython-208b0fb645c0e14b0826c0014e74a0b70c58c9d6.tar.gz
cpython-208b0fb645c0e14b0826c0014e74a0b70c58c9d6.tar.bz2
gh-122431: Disallow negative values in `readline.append_history_file` (#122469)
Co-authored-by: Victor Stinner <vstinner@python.org>
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;