summaryrefslogtreecommitdiffstats
path: root/Python/modsupport.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/modsupport.c')
-rw-r--r--Python/modsupport.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 7b40286..13737f1 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -355,8 +355,15 @@ do_mkvalue(p_format, p_va)
Py_INCREF(v);
}
else {
- if (n < 0)
- n = strlen(str);
+ if (n < 0) {
+ size_t m = strlen(str);
+ if (m > INT_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "string too long for Python string");
+ return NULL;
+ }
+ n = (int)m;
+ }
v = PyString_FromStringAndSize(str, n);
}
return v;