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
This commit is contained in:
Yann Noutary 2024-11-20 01:24:28 -08:00 committed by Facebook GitHub Bot
parent 81d82980bc
commit 91c9f34137

View File

@ -728,7 +728,7 @@ __device__ inline int BoxIntersections(
}
}
// Update the face_verts_out tris
num_tris = offset;
num_tris = min(MAX_TRIS, offset);
for (int j = 0; j < num_tris; ++j) {
face_verts_out[j] = tri_verts_updated[j];
}