Skip to content

pybricks.tools: Fix crash when cross() args are wrong type. #377

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pybricks/tools/pb_type_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pb_geometry_vector_obj, 2, 3, pb_geometry_ve

// pybricks.tools.cross
static mp_obj_t pb_type_matrix_cross(mp_obj_t a_in, mp_obj_t b_in) {
if (!mp_obj_is_type(a_in, &pb_type_Matrix) || !mp_obj_is_type(b_in, &pb_type_Matrix)) {
mp_raise_TypeError(MP_ERROR_TEXT("arguments must be Matrix objects"));
}

// Get a and b vectors
pb_type_Matrix_obj_t *a = MP_OBJ_TO_PTR(a_in);
Expand Down