Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Segfault fix #218

Merged
merged 1 commit into from
May 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions python/lib/pythontarget.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,6 @@ void destroy_action_capsule(PyObject* capsule) {
* Individual ports can then later be accessed in Python code as port[idx].
*/
PyObject* convert_C_port_to_py(void* port, int width) {
generic_port_instance_struct* cport;
if (width == -2) {
// Not a multiport
cport = (generic_port_instance_struct *)port;
}
// Create the port struct in Python
PyObject* cap =
(PyObject*)PyObject_GC_New(generic_port_capsule_struct, &py_port_capsule_t);
Expand All @@ -433,13 +428,14 @@ PyObject* convert_C_port_to_py(void* port, int width) {
// Fill in the Python port struct
((generic_port_capsule_struct*)cap)->port = capsule;
((generic_port_capsule_struct*)cap)->width = width;
FEDERATED_ASSIGN_FIELDS(((generic_port_capsule_struct*)cap), cport);

if (width == -2) {
generic_port_instance_struct* cport = (generic_port_instance_struct *) port;
FEDERATED_ASSIGN_FIELDS(((generic_port_capsule_struct*)cap), cport);

((generic_port_capsule_struct*)cap)->is_present =
cport->is_present;


if (cport->value == NULL) {
// Value is absent
Py_INCREF(Py_None);
Expand Down