Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
819802da
Commit
819802da
authored
Dec 11, 2019
by
Nils Berg
Committed by
Wenzel Jakob
Dec 11, 2019
Browse files
Fix a memory leak when creating Python3 modules. (#2019)
parent
dc9006db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
include/pybind11/pybind11.h
include/pybind11/pybind11.h
+6
-1
No files found.
include/pybind11/pybind11.h
View file @
819802da
...
@@ -794,11 +794,16 @@ public:
...
@@ -794,11 +794,16 @@ public:
explicit
module
(
const
char
*
name
,
const
char
*
doc
=
nullptr
)
{
explicit
module
(
const
char
*
name
,
const
char
*
doc
=
nullptr
)
{
if
(
!
options
::
show_user_defined_docstrings
())
doc
=
nullptr
;
if
(
!
options
::
show_user_defined_docstrings
())
doc
=
nullptr
;
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
PyModuleDef
*
def
=
n
ew
PyModuleDef
(
);
PyModuleDef
*
def
=
PyMem_N
ew
(
PyModuleDef
,
1
);
std
::
memset
(
def
,
0
,
sizeof
(
PyModuleDef
));
std
::
memset
(
def
,
0
,
sizeof
(
PyModuleDef
));
def
->
m_name
=
name
;
def
->
m_name
=
name
;
def
->
m_doc
=
doc
;
def
->
m_doc
=
doc
;
def
->
m_size
=
-
1
;
def
->
m_size
=
-
1
;
def
->
m_free
=
[](
void
*
module
)
{
if
(
module
!=
nullptr
)
{
Py_XDECREF
(
PyModule_GetDef
((
PyObject
*
)
module
));
}
};
Py_INCREF
(
def
);
Py_INCREF
(
def
);
m_ptr
=
PyModule_Create
(
def
);
m_ptr
=
PyModule_Create
(
def
);
#else
#else
...
...
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