diff Python/modsupport.c @ 13096:8c8de5b736dc legacy-trunk

Trent Mick's Win64 changes: size_t vs. int or long; also some overflow tests.
author Guido van Rossum <guido@python.org>
date Wed, 28 Jun 2000 22:07:35 +0000
parents b6b7bd20c845
children 916fb024ce94
line wrap: on
line diff
--- a/Python/modsupport.c	Wed Jun 28 22:05:44 2000 +0000
+++ b/Python/modsupport.c	Wed Jun 28 22:07:35 2000 +0000
@@ -355,8 +355,15 @@
 				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;