Skip to content

Commit 91c9f34

Browse files
Yann Noutaryfacebook-github-bot
Yann Noutary
authored andcommitted
Add safeguard in case num_tris diverges
Summary: This PR fixes adds a safeguard preventing num_tris to overflow in `MAX_TRIS`-length arrays. The update rule of `num_tris` is bounded : - max(num_tris(t)) = 2*num_tris(t-1) - num_tris(0) = 12 - t <= 6 So : - max(num_tris) = 2^6*12 - max(num_tris) = 768 Reviewed By: bottler Differential Revision: D66162573 fbshipit-source-id: e269a79c75c6cc33306986b1f1256cffbe96c730
1 parent 81d8298 commit 91c9f34

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pytorch3d/csrc/iou_box3d/iou_utils.cuh

+1-1
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ __device__ inline int BoxIntersections(
728728
}
729729
}
730730
// Update the face_verts_out tris
731-
num_tris = offset;
731+
num_tris = min(MAX_TRIS, offset);
732732
for (int j = 0; j < num_tris; ++j) {
733733
face_verts_out[j] = tri_verts_updated[j];
734734
}

0 commit comments

Comments
 (0)