Skip to content

Commit 26976b7

Browse files
committed
Fixup minor use after free issues, and improper mutex usage in meshrepo. Also fixed some compiler warnings.
1 parent d2d172f commit 26976b7

6 files changed

Lines changed: 34 additions & 28 deletions

File tree

indra/llcommon/llsd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ static const char *llsd_dump(const LLSD &llsd, bool useXMLFormat)
936936
out << LLSDNotationStreamer(llsd);
937937
out_string = out.str();
938938
}
939-
int len = out_string.length();
939+
size_t len = out_string.length();
940940
sStorage = new char[len + 1];
941941
memcpy(sStorage, out_string.c_str(), len);
942942
sStorage[len] = '\0';

indra/llmessage/llavatarnamecache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ void LLAvatarNameCache::requestNamesViaCapability()
335335
while(!sAskQueue.empty())
336336
{
337337
it = sAskQueue.begin();
338-
const LLUUID& agent_id = *it;
338+
const LLUUID agent_id = *it;
339339
sAskQueue.erase(it);
340340

341341
if (url.empty())

indra/newview/llfloatermodelpreview.cpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4405,24 +4405,27 @@ bool LLModelPreview::lodQueryCallback()
44054405
// not the best solution, but model preview belongs to floater
44064406
// so it is an easy way to check that preview still exists.
44074407
LLFloaterModelPreview* fmp = LLFloaterModelPreview::sInstance;
4408-
if (fmp && fmp->mModelPreview)
4409-
{
4410-
LLModelPreview* preview = fmp->mModelPreview;
4411-
if (preview->mLodsQuery.size() > 0)
4412-
{
4413-
S32 lod = preview->mLodsQuery.back();
4414-
preview->mLodsQuery.pop_back();
4415-
preview->genLODs(lod);
4408+
if (fmp)
4409+
{
4410+
if (fmp->mModelPreview)
4411+
{
4412+
LLModelPreview* preview = fmp->mModelPreview;
4413+
if (preview->mLodsQuery.size() > 0)
4414+
{
4415+
S32 lod = preview->mLodsQuery.back();
4416+
preview->mLodsQuery.pop_back();
4417+
preview->genLODs(lod);
44164418

4417-
// return false to continue cycle
4418-
return false;
4419-
}
4420-
}
4419+
// return false to continue cycle
4420+
return false;
4421+
}
4422+
}
44214423

4422-
for (U32 lod = 0; lod < NUM_LOD; ++lod)
4423-
{
4424-
LLIconCtrl* icon = fmp->getChild<LLIconCtrl>(lod_icon_name[lod]);
4425-
icon->setVisible(true);
4424+
for (U32 lod = 0; lod < NUM_LOD; ++lod)
4425+
{
4426+
LLIconCtrl* icon = fmp->getChild<LLIconCtrl>(lod_icon_name[lod]);
4427+
icon->setVisible(true);
4428+
}
44264429
}
44274430

44284431
// nothing to process

indra/newview/llmaterialmgr.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ LLMaterialMgr::~LLMaterialMgr()
134134
bool LLMaterialMgr::isGetPending(const LLUUID& region_id, const LLMaterialID& material_id) const
135135
{
136136
get_pending_map_t::const_iterator itPending = mGetPending.find(pending_material_t(region_id, material_id));
137-
return (mGetPending.end() != itPending) && (LLFrameTimer::getTotalSeconds() < itPending->second + MATERIALS_POST_TIMEOUT);
137+
return (mGetPending.end() != itPending) && (LLFrameTimer::getTotalSeconds() < itPending->second + F64(MATERIALS_POST_TIMEOUT));
138138
}
139139

140140
void LLMaterialMgr::markGetPending(const LLUUID& region_id, const LLMaterialID& material_id)
@@ -270,7 +270,7 @@ boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const
270270
bool LLMaterialMgr::isGetAllPending(const LLUUID& region_id) const
271271
{
272272
getall_pending_map_t::const_iterator itPending = mGetAllPending.find(region_id);
273-
return (mGetAllPending.end() != itPending) && (LLFrameTimer::getTotalSeconds() < itPending->second + MATERIALS_GET_TIMEOUT);
273+
return (mGetAllPending.end() != itPending) && (LLFrameTimer::getTotalSeconds() < itPending->second + F64(MATERIALS_GET_TIMEOUT));
274274
}
275275

276276
void LLMaterialMgr::getAll(const LLUUID& region_id)
@@ -583,7 +583,7 @@ void LLMaterialMgr::processGetQueue()
583583
{
584584
get_queue_t::iterator itRegionQueue = loopRegionQueue++;
585585

586-
const LLUUID& region_id = itRegionQueue->first;
586+
const LLUUID region_id = itRegionQueue->first;
587587
if (isGetAllPending(region_id))
588588
{
589589
continue;
@@ -621,12 +621,12 @@ void LLMaterialMgr::processGetQueue()
621621
material_queue_t& materials = itRegionQueue->second;
622622
U32 max_entries = regionp->getMaxMaterialsPerTransaction();
623623
material_queue_t::iterator loopMaterial = materials.begin();
624-
while ( (materials.end() != loopMaterial) && (materialsData.size() < (int)max_entries) )
624+
while ( (materials.end() != loopMaterial) && ((U32)materialsData.size() < max_entries) )
625625
{
626626
material_queue_t::iterator itMaterial = loopMaterial++;
627627
materialsData.append((*itMaterial).asLLSD());
628-
materials.erase(itMaterial);
629628
markGetPending(region_id, *itMaterial);
629+
materials.erase(itMaterial);
630630
}
631631
if (materials.empty())
632632
{
@@ -727,7 +727,7 @@ void LLMaterialMgr::processPutQueue()
727727
facematerial_map_t& face_map = itQueue->second;
728728
U32 max_entries = regionp->getMaxMaterialsPerTransaction();
729729
facematerial_map_t::iterator itFace = face_map.begin();
730-
while ( (face_map.end() != itFace) && (facesData.size() < (int)max_entries) )
730+
while ( (face_map.end() != itFace) && ((U32)facesData.size() < max_entries) )
731731
{
732732
LLSD faceData = LLSD::emptyMap();
733733
faceData[MATERIALS_CAP_FACE_FIELD] = static_cast<LLSD::Integer>(itFace->first);

indra/newview/llmeshrepository.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -742,10 +742,13 @@ void LLMeshRepoThread::lockAndLoadMeshLOD(const LLVolumeParams& mesh_params, S32
742742

743743
void LLMeshRepoThread::loadMeshLOD(const LLVolumeParams& mesh_params, S32 lod)
744744
{ //could be called from any thread
745+
std::unique_lock<LLMutex> header_lock(*mHeaderMutex);
746+
bool exists = mMeshHeader.find(mesh_params.getSculptID()) != mMeshHeader.end();
747+
header_lock.unlock();
745748
LLMutexLock lock(mMutex);
746-
mesh_header_map::iterator iter = mMeshHeader.find(mesh_params.getSculptID());
747-
if (iter != mMeshHeader.end())
748-
{ //if we have the header, request LOD byte range
749+
if (exists)
750+
{
751+
//if we have the header, request LOD byte range
749752
gMeshRepo.mThread->pushLODRequest(mesh_params, lod, 0.f);
750753
LLMeshRepository::sLODProcessing++;
751754
}

indra/newview/llsurface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ BOOL LLSurface::idleUpdate(F32 max_update_time)
596596

597597
// Always call updateNormals() / updateVerticalStats()
598598
// every frame to avoid artifacts
599-
for (auto& it = mDirtyPatchList.cbegin(); it != mDirtyPatchList.cend();)
599+
for (auto it = mDirtyPatchList.cbegin(); it != mDirtyPatchList.cend();)
600600
{
601601
if (it->second.expired())
602602
{

0 commit comments

Comments
 (0)