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
12f33df4
Commit
12f33df4
authored
Dec 08, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Issue #16628: Fix a memory leak in ctypes.resize().
parents
f04d1bb1
305e1a74
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
2 deletions
+5
-2
Misc/NEWS
Misc/NEWS
+2
-0
Modules/_ctypes/_ctypes.c
Modules/_ctypes/_ctypes.c
+1
-1
Modules/_ctypes/callproc.c
Modules/_ctypes/callproc.c
+1
-1
Modules/_ctypes/ctypes.h
Modules/_ctypes/ctypes.h
+1
-0
No files found.
Misc/NEWS
View file @
12f33df4
...
...
@@ -104,6 +104,8 @@ Core and Builtins
Library
-------
-
Issue
#
16628
:
Fix
a
memory
leak
in
ctypes
.
resize
().
-
Issue
#
13120
:
Allow
to
call
pdb
.
set_trace
()
from
thread
.
Patch
by
Ilya
Sandler
.
...
...
Modules/_ctypes/_ctypes.c
View file @
12f33df4
...
...
@@ -2446,7 +2446,7 @@ PyCData_clear(CDataObject *self)
assert
(
dict
);
/* Cannot be NULL for CDataObject instances */
Py_CLEAR
(
self
->
b_objects
);
if
((
self
->
b_needsfree
)
&&
((
size_t
)
dict
->
size
>
sizeof
(
self
->
b_value
)
))
&&
_CDataObject_HasExternalBuffer
(
self
))
PyMem_Free
(
self
->
b_ptr
);
self
->
b_ptr
=
NULL
;
Py_CLEAR
(
self
->
b_base
);
...
...
Modules/_ctypes/callproc.c
View file @
12f33df4
...
...
@@ -1658,7 +1658,7 @@ resize(PyObject *self, PyObject *args)
obj
->
b_size
=
size
;
goto
done
;
}
if
(
obj
->
b_size
<=
sizeof
(
obj
->
b_value
))
{
if
(
!
_CDataObject_HasExternalBuffer
(
obj
))
{
/* We are currently using the objects default buffer, but it
isn't large enough any more. */
void
*
ptr
=
PyMem_Malloc
(
size
);
...
...
Modules/_ctypes/ctypes.h
View file @
12f33df4
...
...
@@ -116,6 +116,7 @@ extern int PyObject_stginfo(PyObject *self, Py_ssize_t *psize, Py_ssize_t *palig
extern
PyTypeObject
PyCData_Type
;
#define CDataObject_CheckExact(v) ((v)->ob_type == &PyCData_Type)
#define CDataObject_Check(v) PyObject_TypeCheck(v, &PyCData_Type)
#define _CDataObject_HasExternalBuffer(v) ((v)->b_ptr != (char *)&(v)->b_value)
extern
PyTypeObject
PyCSimpleType_Type
;
#define PyCSimpleTypeObject_CheckExact(v) ((v)->ob_type == &PyCSimpleType_Type)
...
...
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