summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-06-28 22:07:35 (GMT)
committerGuido van Rossum <guido@python.org>2000-06-28 22:07:35 (GMT)
commit582acece2e0db447904b3f8f8f1d2acf36834158 (patch)
tree80805422d52a32da77e5e93425c34ec48d76a9c6 /Python/compile.c
parent6f2a5efec98c831bd529dfb341c2f83ff0914418 (diff)
downloadcpython-582acece2e0db447904b3f8f8f1d2acf36834158.zip
cpython-582acece2e0db447904b3f8f8f1d2acf36834158.tar.gz
cpython-582acece2e0db447904b3f8f8f1d2acf36834158.tar.bz2
Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
tests.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/Python/compile.c b/Python/compile.c
index a387317..4373422 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -265,8 +265,8 @@ PyCode_New(argcount, nlocals, stacksize, flags,
if (!PyString_Check(v))
continue;
p = PyString_AsString(v);
- if ((int)strspn(p, NAME_CHARS)
- != PyString_Size(v))
+ if (strspn(p, NAME_CHARS)
+ != (size_t)PyString_Size(v))
continue;
PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i));
}
@@ -340,7 +340,7 @@ com_error(c, exc, msg)
PyObject *exc;
char *msg;
{
- int n = strlen(msg);
+ size_t n = strlen(msg);
PyObject *v;
char buffer[30];
char *s;
@@ -720,12 +720,12 @@ com_mangle(c, name, buffer, maxlen)
struct compiling *c;
char *name;
char *buffer;
- int maxlen;
+ size_t maxlen;
{
/* Name mangling: __private becomes _classname__private.
This is independent from how the name is used. */
char *p;
- int nlen, plen;
+ size_t nlen, plen;
nlen = strlen(name);
if (nlen+2 >= maxlen)
return 0; /* Don't mangle __extremely_long_names */
@@ -761,7 +761,7 @@ com_addopnamestr(c, op, name)
char buffer[256];
if (name != NULL && name[0] == '_' && name[1] == '_' &&
c->c_private != NULL &&
- com_mangle(c, name, buffer, (int)sizeof(buffer)))
+ com_mangle(c, name, buffer, sizeof(buffer)))
name = buffer;
#endif
if (name == NULL || (v = PyString_InternFromString(name)) == NULL) {
@@ -883,7 +883,7 @@ parsestr(s)
char *s;
{
PyObject *v;
- int len;
+ size_t len;
char *buf;
char *p;
char *end;
@@ -908,6 +908,10 @@ parsestr(s)
}
s++;
len = strlen(s);
+ if (len > INT_MAX) {
+ PyErr_SetString(PyExc_OverflowError, "string to parse is too long");
+ return NULL;
+ }
if (s[--len] != quote) {
PyErr_BadInternalCall();
return NULL;
@@ -2201,7 +2205,7 @@ com_global_stmt(c, n)
char buffer[256];
if (s != NULL && s[0] == '_' && s[1] == '_' &&
c->c_private != NULL &&
- com_mangle(c, s, buffer, (int)sizeof(buffer)))
+ com_mangle(c, s, buffer, sizeof(buffer)))
s = buffer;
#endif
if (PyDict_GetItemString(c->c_locals, s) != NULL) {