Check if STL vertex coordinates are within maximum bounds.
PiperOrigin-RevId: 464047975 Change-Id: I5c8c32aca468aaee26ff5cf9466a0f2f81721010
This commit is contained in:
committed by
Copybara-Service
parent
8ead54d2dc
commit
cd489fc72d
@@ -688,6 +688,17 @@ void mjCMesh::LoadSTL(const mjVFS* vfs) {
|
|||||||
// get pointer to vertex coordiates
|
// get pointer to vertex coordiates
|
||||||
float* v = (float*)(stl+50*i+12*(j+1));
|
float* v = (float*)(stl+50*i+12*(j+1));
|
||||||
|
|
||||||
|
// check if vertex coordinates can be cast to an int safely
|
||||||
|
if (fabs(v[0])>pow(2, 30) || fabs(v[1])>pow(2, 30) || fabs(v[2])>pow(2, 30)) {
|
||||||
|
if (!flag_existing) {
|
||||||
|
mju_free(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw mjCError(this,
|
||||||
|
"vertex coordinates in STL file '%s' exceed maximum bounds",
|
||||||
|
filename.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
// add vertex address in face; change order if scale makes it lefthanded
|
// add vertex address in face; change order if scale makes it lefthanded
|
||||||
if (righthand || j==0) {
|
if (righthand || j==0) {
|
||||||
face[3*i+j] = nvert;
|
face[3*i+j] = nvert;
|
||||||
|
|||||||
Reference in New Issue
Block a user