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
@@ -1879,7 +1879,8 @@ void mjCHField::Compile(const mjVFS* vfs) {
|
||||
string filename = mjuu_makefullname(model->modelfiledir, model->meshdir, file);
|
||||
|
||||
// load depending on format
|
||||
if (!strcasecmp(filename.substr(filename.length()-4, 5).c_str(), ".png")) {
|
||||
string ext = mjuu_getext(filename);
|
||||
if (!strcasecmp(ext.c_str(), ".png")) {
|
||||
LoadPNG(filename, vfs);
|
||||
} else {
|
||||
LoadCustom(filename, vfs);
|
||||
@@ -2301,7 +2302,8 @@ void mjCTexture::LoadFlip(string filename, const mjVFS* vfs,
|
||||
std::vector<unsigned char>& image,
|
||||
unsigned int& w, unsigned int& h) {
|
||||
// dispatch to PNG or Custom loaded
|
||||
if (!strcasecmp(filename.substr(filename.length()-4, 5).c_str(), ".png")) {
|
||||
string ext = mjuu_getext(filename);
|
||||
if (!strcasecmp(ext.c_str(), ".png")) {
|
||||
LoadPNG(filename, vfs, image, w, h);
|
||||
} else {
|
||||
LoadCustom(filename, vfs, image, w, h);
|
||||
|
||||
Reference in New Issue
Block a user