Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cae5a8e

Browse files
committed
Merge pull request matplotlib#3797 from ianthomas23/3789_segfault
Fix for matplotlib#3789, segfault in _tri
2 parents 80d0565 + c80f0e1 commit cae5a8e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/matplotlib/tri/_tri.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,8 @@ int Triangulation::get_triangle_point(const TriEdge& tri_edge) const
530530
bool Triangulation::is_masked(int tri) const
531531
{
532532
assert(tri >= 0 && tri < get_ntri() && "Triangle index out of bounds.");
533-
return !_mask.empty() && _mask(tri);
533+
const npy_bool* mask_ptr = reinterpret_cast<const npy_bool*>(_mask.data());
534+
return !_mask.empty() && mask_ptr[tri];
534535
}
535536

536537
void Triangulation::set_mask(const MaskArray& mask)

src/numpy_cpp.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,12 @@ class array_view : public detail::array_view_accessors<array_view, T, ND>
479479
return size() == 0;
480480
}
481481

482+
// Do not use this for array_view<bool, ND>. See comment near top of file.
483+
const T *data() const
484+
{
485+
return (const T *)m_data;
486+
}
487+
482488
// Do not use this for array_view<bool, ND>. See comment near top of file.
483489
T *data()
484490
{

0 commit comments

Comments
 (0)