Skip to content

Commit

Permalink
Fix for matplotlib#3789, segfault in _tri
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthomas23 committed Nov 14, 2014
1 parent 80d0565 commit c80f0e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/matplotlib/tri/_tri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,8 @@ int Triangulation::get_triangle_point(const TriEdge& tri_edge) const
bool Triangulation::is_masked(int tri) const
{
assert(tri >= 0 && tri < get_ntri() && "Triangle index out of bounds.");
return !_mask.empty() && _mask(tri);
const npy_bool* mask_ptr = reinterpret_cast<const npy_bool*>(_mask.data());
return !_mask.empty() && mask_ptr[tri];
}

void Triangulation::set_mask(const MaskArray& mask)
Expand Down
6 changes: 6 additions & 0 deletions src/numpy_cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,12 @@ class array_view : public detail::array_view_accessors<array_view, T, ND>
return size() == 0;
}

// Do not use this for array_view<bool, ND>. See comment near top of file.
const T *data() const
{
return (const T *)m_data;
}

// Do not use this for array_view<bool, ND>. See comment near top of file.
T *data()
{
Expand Down

0 comments on commit c80f0e1

Please sign in to comment.