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
1e211ff1
Commit
1e211ff1
authored
Oct 15, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
it suffices to check for PY_SSIZE_T_MAX overflow (#22643)
parent
c0e64f50
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
3 deletions
+2
-3
Objects/unicodeobject.c
Objects/unicodeobject.c
+2
-3
No files found.
Objects/unicodeobject.c
View file @
1e211ff1
...
@@ -9484,12 +9484,11 @@ case_operation(PyObject *self,
...
@@ -9484,12 +9484,11 @@ case_operation(PyObject *self,
kind
=
PyUnicode_KIND
(
self
);
kind
=
PyUnicode_KIND
(
self
);
data
=
PyUnicode_DATA
(
self
);
data
=
PyUnicode_DATA
(
self
);
length
=
PyUnicode_GET_LENGTH
(
self
);
length
=
PyUnicode_GET_LENGTH
(
self
);
if
(
length
>
PY_SSIZE_T_MAX
/
3
||
if
(
length
>
PY_SSIZE_T_MAX
/
(
3
*
sizeof
(
Py_UCS4
)))
{
length
>
PY_SIZE_MAX
/
(
3
*
sizeof
(
Py_UCS4
)))
{
PyErr_SetString
(
PyExc_OverflowError
,
"string is too long"
);
PyErr_SetString
(
PyExc_OverflowError
,
"string is too long"
);
return
NULL
;
return
NULL
;
}
}
tmp
=
PyMem_MALLOC
(
sizeof
(
Py_UCS4
)
*
3
*
(
size_t
)
length
);
tmp
=
PyMem_MALLOC
(
sizeof
(
Py_UCS4
)
*
3
*
length
);
if
(
tmp
==
NULL
)
if
(
tmp
==
NULL
)
return
PyErr_NoMemory
();
return
PyErr_NoMemory
();
newlength
=
perform
(
kind
,
data
,
length
,
tmp
,
&
maxchar
);
newlength
=
perform
(
kind
,
data
,
length
,
tmp
,
&
maxchar
);
...
...
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