Avoid out-of-bounds access when checking file extensions.
Include the '.' in the file extension check. PiperOrigin-RevId: 474866478 Change-Id: I809ae975e4c8b00f17278735975a7d07e0748643
This commit is contained in:
committed by
Copybara-Service
parent
68718e76b1
commit
f556d4d94f
@@ -160,12 +160,12 @@ void mjCMesh::Compile(const mjVFS* vfs) {
|
||||
}
|
||||
|
||||
// load STL, OBJ or MSH
|
||||
string ext = file.substr(file.size()-3, 3);
|
||||
if (!strcasecmp(ext.c_str(), "stl")) {
|
||||
string ext = mjuu_getext(file);
|
||||
if (!strcasecmp(ext.c_str(), ".stl")) {
|
||||
LoadSTL(vfs);
|
||||
} else if (!strcasecmp(ext.c_str(), "obj")) {
|
||||
} else if (!strcasecmp(ext.c_str(), ".obj")) {
|
||||
LoadOBJ(vfs);
|
||||
} else if (!strcasecmp(ext.c_str(), "msh")) {
|
||||
} else if (!strcasecmp(ext.c_str(), ".msh")) {
|
||||
LoadMSH(vfs);
|
||||
} else {
|
||||
throw mjCError(this, "Unknown mesh file type: %s", file.c_str());
|
||||
@@ -1621,8 +1621,8 @@ void mjCSkin::Compile(const mjVFS* vfs) {
|
||||
}
|
||||
|
||||
// load SKN
|
||||
string ext = file.substr(file.size()-3, 3);
|
||||
if (!strcasecmp(ext.c_str(), "skn")) {
|
||||
string ext = mjuu_getext(file);
|
||||
if (!strcasecmp(ext.c_str(), ".skn")) {
|
||||
LoadSKN(vfs);
|
||||
} else {
|
||||
throw mjCError(this, "Unknown skin file type: %s", file.c_str());
|
||||
|
||||
Reference in New Issue
Block a user