From 55d04f9a23e995bfc74182374e4346d839a05c5d Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Wed, 11 Jun 2008 07:41:16 +0000 Subject: Merge in release25-maint r60793: Added checks for integer overflows, contributed by Google. Some are only available if asserts are left in the code, in cases where they can't be triggered from Python code. --- Parser/node.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Parser') diff --git a/Parser/node.c b/Parser/node.c index d133a0d178..f4c86cb0ff 100644 --- a/Parser/node.c +++ b/Parser/node.c @@ -91,6 +91,9 @@ PyNode_AddChild(register node *n1, int type, char *str, int lineno, int col_offs if (current_capacity < 0 || required_capacity < 0) return E_OVERFLOW; if (current_capacity < required_capacity) { + if (required_capacity > PY_SIZE_MAX / sizeof(node)) { + return E_NOMEM; + } n = n1->n_child; n = (node *) PyObject_REALLOC(n, required_capacity * sizeof(node)); -- cgit v1.2.1