Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix subplot args convert#355

Open
Sologala wants to merge 2 commits into
lava:master from
Sologala:fix_py3_subplot
Open

Fix subplot args convert #355
Sologala wants to merge 2 commits into
lava:master from
Sologala:fix_py3_subplot

Conversation

@Sologala

@Sologala Sologala commented Nov 8, 2023
edited
Loading

Copy link
Copy Markdown

Unproperly args converting in void subplot(long , long , long) may cause segment fault.

matplotlib-cpp/matplotlibcpp.h

Lines 2252 to 2267 in 2acb4d0

inline void subplot(long nrows, long ncols, long plot_number)
{
detail::_interpreter::get();
// construct positional args
PyObject* args = PyTuple_New(3);
PyTuple_SetItem(args, 0, PyLong_FromLong(nrows));
PyTuple_SetItem(args, 1, PyLong_FromLong(ncols));
PyTuple_SetItem(args, 2, PyLong_FromLong(plot_number));
PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_subplot, args);
if(!res) throw std::runtime_error("Call to subplot() failed.");
Py_DECREF(args);
Py_DECREF(res);
}

Copy link
Copy Markdown

The implicit conversion part is a duplicate of #333

Copy link
Copy Markdown

Would double conversion also cause a seg fault? I am using this it seems to work.

 PyObject* args = PyTuple_New(3); 
 PyTuple_SetItem(args, 0, PyDouble_FromLong(nrows)); 
 PyTuple_SetItem(args, 1, PyDouble_FromLong(ncols)); 
 PyTuple_SetItem(args, 2, PyDouble_FromLong(plot_number)); 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /