Skip to content
Snippets Groups Projects
Commit e1fd58c5 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Prevent invalid array access during loadModel

parent 71646e47
Branches
Tags
No related merge requests found
...@@ -1116,18 +1116,15 @@ bool LLModel::loadModel(std::istream& is) ...@@ -1116,18 +1116,15 @@ bool LLModel::loadModel(std::istream& is)
mSubmodelID = header.has("submodel_id") ? header["submodel_id"].asInteger() : false; mSubmodelID = header.has("submodel_id") ? header["submodel_id"].asInteger() : false;
static const std::string lod_name[] = static const std::array<std::string, 5> lod_name = {{
{
"lowest_lod", "lowest_lod",
"low_lod", "low_lod",
"medium_lod", "medium_lod",
"high_lod", "high_lod",
"physics_mesh", "physics_mesh",
}; }};
const S32 MODEL_LODS = 5;
S32 lod = llclamp((S32) mDetail, 0, MODEL_LODS); S32 lod = llclamp(static_cast<S32>(mDetail), 0, static_cast<S32>(lod_name.size()) - 1);
if (header[lod_name[lod]]["offset"].asInteger() == -1 || if (header[lod_name[lod]]["offset"].asInteger() == -1 ||
header[lod_name[lod]]["size"].asInteger() == 0 ) header[lod_name[lod]]["size"].asInteger() == 0 )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment