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
0516f818
Commit
0516f818
authored
Mar 25, 2019
by
Zackery Spytz
Committed by
Serhiy Storchaka
Mar 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.7] bpo-36421: Fix ref counting bugs in _ctypes.c's PyCArrayType_new(). (GH-12534)
Add missing Py_DECREF()s.
parent
469b0a50
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
Modules/_ctypes/_ctypes.c
Modules/_ctypes/_ctypes.c
+10
-3
No files found.
Modules/_ctypes/_ctypes.c
View file @
0516f818
...
...
@@ -1537,6 +1537,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if
(
length
*
itemsize
<
0
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"array too large"
);
Py_DECREF
(
stgdict
);
return
NULL
;
}
...
...
@@ -1559,8 +1560,10 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
/* create the new instance (which is a class,
since we are a metatype!) */
result
=
(
PyTypeObject
*
)
PyType_Type
.
tp_new
(
type
,
args
,
kwds
);
if
(
result
==
NULL
)
if
(
result
==
NULL
)
{
Py_DECREF
(
stgdict
);
return
NULL
;
}
/* replace the class dict by our updated spam dict */
if
(
-
1
==
PyDict_Update
((
PyObject
*
)
stgdict
,
result
->
tp_dict
))
{
...
...
@@ -1574,12 +1577,16 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
A permanent annoyance: char arrays are also strings!
*/
if
(
itemdict
->
getfunc
==
_ctypes_get_fielddesc
(
"c"
)
->
getfunc
)
{
if
(
-
1
==
add_getset
(
result
,
CharArray_getsets
))
if
(
-
1
==
add_getset
(
result
,
CharArray_getsets
))
{
Py_DECREF
(
result
);
return
NULL
;
}
#ifdef CTYPES_UNICODE
}
else
if
(
itemdict
->
getfunc
==
_ctypes_get_fielddesc
(
"u"
)
->
getfunc
)
{
if
(
-
1
==
add_getset
(
result
,
WCharArray_getsets
))
if
(
-
1
==
add_getset
(
result
,
WCharArray_getsets
))
{
Py_DECREF
(
result
);
return
NULL
;
}
#endif
}
...
...
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