summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 5ac4ac9..ed5e196 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2710,6 +2710,13 @@ _PySequence_BytesToCharpArray(PyObject* self)
if (argc == -1)
return NULL;
+ assert(argc >= 0);
+
+ if ((size_t)argc > (PY_SSIZE_T_MAX-sizeof(char *)) / sizeof(char *)) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
array = malloc((argc + 1) * sizeof(char *));
if (array == NULL) {
PyErr_NoMemory();