Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
623fdb98
Commit
623fdb98
authored
Jul 08, 2002
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PyNode_AddChild() and fancy_roundup(): Be paranoid about int overflow.
parent
cccd1e72
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
Parser/node.c
Parser/node.c
+7
-2
No files found.
Parser/node.c
View file @
623fdb98
...
...
@@ -18,15 +18,18 @@ PyNode_New(int type)
return
n
;
}
/* See comments at XXXROUNDUP below. */
/* See comments at XXXROUNDUP below.
Returns -1 on overflow.
*/
static
int
fancy_roundup
(
int
n
)
{
/* Round up to the closest power of 2 >= n. */
int
result
=
256
;
assert
(
n
>
128
);
while
(
result
<
n
)
while
(
result
<
n
)
{
result
<<=
1
;
if
(
result
<=
0
)
return
-
1
;
}
return
result
;
}
...
...
@@ -62,6 +65,8 @@ PyNode_AddChild(register node *n1, int type, char *str, int lineno)
current_capacity
=
XXXROUNDUP
(
nch
);
required_capacity
=
XXXROUNDUP
(
nch
+
1
);
if
(
current_capacity
<
0
||
required_capacity
<
0
)
return
E_OVERFLOW
;
if
(
current_capacity
<
required_capacity
)
{
n
=
n1
->
n_child
;
PyMem_RESIZE
(
n
,
node
,
required_capacity
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment