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
7c99ff2a
Commit
7c99ff2a
authored
Jun 02, 2016
by
Wenzel Jakob
Browse files
fix segfault when passing a docstring to def_property* (fixes #222)
parent
9767c480
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
include/pybind11/pybind11.h
include/pybind11/pybind11.h
+12
-1
No files found.
include/pybind11/pybind11.h
View file @
7c99ff2a
...
...
@@ -860,9 +860,20 @@ public:
template
<
typename
...
Extra
>
class_
&
def_property_static
(
const
char
*
name
,
const
cpp_function
&
fget
,
const
cpp_function
&
fset
,
const
Extra
&
...
extra
)
{
auto
rec_fget
=
get_function_record
(
fget
),
rec_fset
=
get_function_record
(
fset
);
char
*
doc_prev
=
rec_fget
->
doc
;
/* 'extra' field may include a property-specific documentation string */
detail
::
process_attributes
<
Extra
...
>::
init
(
extra
...,
rec_fget
);
if
(
rec_fset
)
if
(
rec_fget
->
doc
&&
rec_fget
->
doc
!=
doc_prev
)
{
free
(
doc_prev
);
rec_fget
->
doc
=
strdup
(
rec_fget
->
doc
);
}
if
(
rec_fset
)
{
doc_prev
=
rec_fset
->
doc
;
detail
::
process_attributes
<
Extra
...
>::
init
(
extra
...,
rec_fset
);
if
(
rec_fset
->
doc
&&
rec_fset
->
doc
!=
doc_prev
)
{
free
(
doc_prev
);
rec_fset
->
doc
=
strdup
(
rec_fset
->
doc
);
}
}
pybind11
::
str
doc_obj
=
pybind11
::
str
(
rec_fget
->
doc
?
rec_fget
->
doc
:
""
);
object
property
(
PyObject_CallFunctionObjArgs
((
PyObject
*
)
&
PyProperty_Type
,
fget
.
ptr
()
?
fget
.
ptr
()
:
Py_None
,
...
...
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