Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix subplot args convert #355

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

Sologala
Copy link

@Sologala Sologala commented Nov 8, 2023

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);
}

@Timothy-Anders0n
Copy link

The implicit conversion part is a duplicate of #333

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants