Skip to content

Commit

Permalink
fix bytes auto convert memory leak bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Neutree committed May 8, 2024
1 parent 72006b3 commit ee4c7a8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/maix/include/maixpy_bytes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ namespace PYBIND11_NAMESPACE
*/
static handle cast(maix::Bytes *src, return_value_policy /* policy */, handle /* parent */)
{
return PyBytes_FromStringAndSize((char *)src->data, src->data_len);
handle data = PyBytes_FromStringAndSize((char *)src->data, src->data_len);
// TODO: Is there a more efficient way(like borrow src and auto delete src when data or parent deleted)?
delete src;
return data;
}
};
}
Expand Down

0 comments on commit ee4c7a8

Please sign in to comment.