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
48f190f7
Commit
48f190f7
authored
Jun 08, 2019
by
Eric Wieser
Committed by
Stefan Krah
Jun 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.7] bpo-37188: Fix a divide-by-zero in arrays of size-0 objects (#13906)
parent
2bfc2dc2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
Lib/ctypes/test/test_arrays.py
Lib/ctypes/test/test_arrays.py
+15
-0
Modules/_ctypes/_ctypes.c
Modules/_ctypes/_ctypes.c
+1
-1
No files found.
Lib/ctypes/test/test_arrays.py
View file @
48f190f7
...
...
@@ -134,6 +134,21 @@ class ArrayTestCase(unittest.TestCase):
t2
=
my_int
*
1
self
.
assertIs
(
t1
,
t2
)
def
test_empty_element_struct
(
self
):
class
EmptyStruct
(
Structure
):
_fields_
=
[]
obj
=
(
EmptyStruct
*
2
)()
# bpo37188: Floating point exception
self
.
assertEqual
(
sizeof
(
obj
),
0
)
def
test_empty_element_array
(
self
):
class
EmptyArray
(
Array
):
_type_
=
c_int
_length_
=
0
obj
=
(
EmptyArray
*
2
)()
# bpo37188: Floating point exception
self
.
assertEqual
(
sizeof
(
obj
),
0
)
def
test_bpo36504_signed_int_overflow
(
self
):
# The overflow check in PyCArrayType_new() could cause signed integer
# overflow.
...
...
Modules/_ctypes/_ctypes.c
View file @
48f190f7
...
...
@@ -1534,7 +1534,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
itemsize
=
itemdict
->
size
;
if
(
length
>
PY_SSIZE_T_MAX
/
itemsize
)
{
if
(
itemsize
!=
0
&&
length
>
PY_SSIZE_T_MAX
/
itemsize
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"array too large"
);
Py_DECREF
(
stgdict
);
...
...
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