Skip to content

Commit 250f9a9

Browse files
committed
Re-order conditional strides assignment
Avoids possible out-of-bounds access by short-circuiting the if statement
1 parent 1544e9b commit 250f9a9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dpctl/tensor/_dlpack.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ cpdef numpy_to_dlpack_versioned_capsule(ndarray npy_ary, bint copied):
562562
dl_tensor.ndim = nd
563563
dl_tensor.byte_offset = <uint64_t>byte_offset
564564
dl_tensor.shape = &shape_strides_ptr[0]
565-
dl_tensor.strides = &shape_strides_ptr[nd] if not is_c_contiguous else NULL
565+
dl_tensor.strides = NULL if is_c_contiguous else &shape_strides_ptr[nd]
566566
dl_tensor.device.device_type = kDLCPU
567567
dl_tensor.device.device_id = 0
568568
dl_tensor.dtype.lanes = <uint16_t>1

0 commit comments

Comments
 (0)