Skip to content

Commit 9b124b7

Browse files
author
Rye
authored
Merge pull request #3007 from secondlife/rye/crashfixes
Fixes various small memory leaks and some crashes
2 parents a895f4e + 2c7f57b commit 9b124b7

10 files changed

+44
-46
lines changed

indra/llplugin/llpluginprocessparent.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,14 @@ void LLPluginProcessParent::idle(void)
400400
apr_sockaddr_t* addr = NULL;
401401
mListenSocket = LLSocket::create(gAPRPoolp, LLSocket::STREAM_TCP);
402402
mBoundPort = 0;
403+
if (!mListenSocket)
404+
{
405+
killSockets();
406+
errorState();
407+
break;
408+
}
403409

404410
// This code is based on parts of LLSocket::create() in lliosocket.cpp.
405-
406411
status = apr_sockaddr_info_get(
407412
&addr,
408413
"127.0.0.1",

indra/newview/llfloaternotificationstabbed.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ LLFloaterNotificationsTabbed::LLFloaterNotificationsTabbed(const LLSD& key) : LL
4545
mGroupNoticeMessageList(NULL),
4646
mTransactionMessageList(NULL),
4747
mSystemMessageList(NULL),
48-
mNotificationsSeparator(NULL),
4948
mNotificationsTabContainer(NULL),
5049
NOTIFICATION_TABBED_ANCHOR_NAME("notification_well_panel"),
5150
IM_WELL_ANCHOR_NAME("im_well_panel"),
@@ -54,7 +53,7 @@ LLFloaterNotificationsTabbed::LLFloaterNotificationsTabbed(const LLSD& key) : LL
5453
{
5554
setOverlapsScreenChannel(true);
5655
mNotificationUpdates.reset(new NotificationTabbedChannel(this));
57-
mNotificationsSeparator = new LLNotificationSeparator();
56+
mNotificationsSeparator = std::make_unique<LLNotificationSeparator>();
5857
}
5958

6059
//---------------------------------------------------------------------------------
@@ -117,6 +116,7 @@ void LLFloaterNotificationsTabbed::setSysWellChiclet(LLSysWellChiclet* chiclet)
117116
//---------------------------------------------------------------------------------
118117
LLFloaterNotificationsTabbed::~LLFloaterNotificationsTabbed()
119118
{
119+
mNotificationsSeparator.reset();
120120
}
121121

122122
//---------------------------------------------------------------------------------

indra/newview/llfloaternotificationstabbed.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class LLFloaterNotificationsTabbed : public LLTransientDockableFloater
162162
LLNotificationListView* mGroupNoticeMessageList;
163163
LLNotificationListView* mTransactionMessageList;
164164
LLNotificationListView* mSystemMessageList;
165-
LLNotificationSeparator* mNotificationsSeparator;
165+
std::unique_ptr<LLNotificationSeparator> mNotificationsSeparator;
166166
LLTabContainer* mNotificationsTabContainer;
167167
LLButton* mDeleteAllBtn;
168168
LLButton* mCollapseAllBtn;

indra/newview/llfloateruipreview.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -701,13 +701,9 @@ void LLFloaterUIPreview::refreshList()
701701
// Note: no deduplification (shouldn't be necessary)
702702
void LLFloaterUIPreview::addFloaterEntry(const std::string& path)
703703
{
704-
LLUUID* entry_id = new LLUUID(); // create a new UUID
705-
entry_id->generate(path);
706-
const LLUUID& entry_id_ref = *entry_id; // get a reference to the UUID for the LLSD block
707-
708704
// fill LLSD column entry: initialize row/col structure
709705
LLSD row;
710-
row["id"] = entry_id_ref;
706+
row["id"] = LLUUID::generateNewID(path); // create a new UUID;
711707
LLSD& columns = row["columns"];
712708

713709
// Get name of floater:

indra/newview/llmarketplacefunctions.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -450,37 +450,34 @@ LLMarketplaceInventoryImporter::LLMarketplaceInventoryImporter()
450450
, mImportInProgress(false)
451451
, mInitialized(false)
452452
, mMarketPlaceStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_INITIALIZED)
453-
, mErrorInitSignal(NULL)
454-
, mStatusChangedSignal(NULL)
455-
, mStatusReportSignal(NULL)
456453
{
457454
}
458455

459456
boost::signals2::connection LLMarketplaceInventoryImporter::setInitializationErrorCallback(const status_report_signal_t::slot_type& cb)
460457
{
461-
if (mErrorInitSignal == NULL)
458+
if (mErrorInitSignal == nullptr)
462459
{
463-
mErrorInitSignal = new status_report_signal_t();
460+
mErrorInitSignal = std::make_unique<status_report_signal_t>();
464461
}
465462

466463
return mErrorInitSignal->connect(cb);
467464
}
468465

469466
boost::signals2::connection LLMarketplaceInventoryImporter::setStatusChangedCallback(const status_changed_signal_t::slot_type& cb)
470467
{
471-
if (mStatusChangedSignal == NULL)
468+
if (mStatusChangedSignal == nullptr)
472469
{
473-
mStatusChangedSignal = new status_changed_signal_t();
470+
mStatusChangedSignal = std::make_unique<status_changed_signal_t>();
474471
}
475472

476473
return mStatusChangedSignal->connect(cb);
477474
}
478475

479476
boost::signals2::connection LLMarketplaceInventoryImporter::setStatusReportCallback(const status_report_signal_t::slot_type& cb)
480477
{
481-
if (mStatusReportSignal == NULL)
478+
if (mStatusReportSignal == nullptr)
482479
{
483-
mStatusReportSignal = new status_report_signal_t();
480+
mStatusReportSignal = std::make_unique<status_report_signal_t>();
484481
}
485482

486483
return mStatusReportSignal->connect(cb);
@@ -717,8 +714,6 @@ LLMarketplaceTuple::LLMarketplaceTuple(const LLUUID& folder_id, S32 listing_id,
717714
LLMarketplaceData::LLMarketplaceData() :
718715
mMarketPlaceStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_INITIALIZED),
719716
mMarketPlaceDataFetched(MarketplaceFetchCodes::MARKET_FETCH_NOT_DONE),
720-
mStatusUpdatedSignal(NULL),
721-
mDataFetchedSignal(NULL),
722717
mDirtyCount(false)
723718
{
724719
mInventoryObserver = new LLMarketplaceInventoryObserver;
@@ -752,9 +747,9 @@ LLSD LLMarketplaceData::getMarketplaceStringSubstitutions()
752747

753748
void LLMarketplaceData::initializeSLM(const status_updated_signal_t::slot_type& cb)
754749
{
755-
if (mStatusUpdatedSignal == NULL)
750+
if (mStatusUpdatedSignal == nullptr)
756751
{
757-
mStatusUpdatedSignal = new status_updated_signal_t();
752+
mStatusUpdatedSignal = std::make_unique<status_updated_signal_t>();
758753
}
759754
mStatusUpdatedSignal->connect(cb);
760755

@@ -842,7 +837,7 @@ void LLMarketplaceData::setDataFetchedSignal(const status_updated_signal_t::slot
842837
{
843838
if (mDataFetchedSignal == NULL)
844839
{
845-
mDataFetchedSignal = new status_updated_signal_t();
840+
mDataFetchedSignal = std::make_unique<status_updated_signal_t>();
846841
}
847842
mDataFetchedSignal->connect(cb);
848843
}

indra/newview/llmarketplacefunctions.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ class LLMarketplaceInventoryImporter
113113
bool mInitialized;
114114
U32 mMarketPlaceStatus;
115115

116-
status_report_signal_t * mErrorInitSignal;
117-
status_changed_signal_t * mStatusChangedSignal;
118-
status_report_signal_t * mStatusReportSignal;
116+
std::unique_ptr<status_report_signal_t> mErrorInitSignal;
117+
std::unique_ptr<status_changed_signal_t> mStatusChangedSignal;
118+
std::unique_ptr<status_report_signal_t> mStatusReportSignal;
119119
};
120120

121121

@@ -276,13 +276,13 @@ class LLMarketplaceData
276276
// Handling Marketplace connection and inventory connection
277277
U32 mMarketPlaceStatus;
278278
std::string mMarketPlaceFailureReason;
279-
status_updated_signal_t* mStatusUpdatedSignal;
279+
std::unique_ptr<status_updated_signal_t> mStatusUpdatedSignal;
280280
LLInventoryObserver* mInventoryObserver;
281281
bool mDirtyCount; // If true, stock count value need to be updated at the next check
282282

283283
// Update data
284284
U32 mMarketPlaceDataFetched;
285-
status_updated_signal_t* mDataFetchedSignal;
285+
std::unique_ptr<status_updated_signal_t> mDataFetchedSignal;
286286
std::set<LLUUID> mPendingUpdateSet;
287287

288288
// Listing folders waiting for validation

indra/newview/llmaterialmgr.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ boost::signals2::connection LLMaterialMgr::get(const LLUUID& region_id, const LL
234234
get_callback_map_t::iterator itCallback = mGetCallbacks.find(material_id);
235235
if (itCallback == mGetCallbacks.end())
236236
{
237-
std::pair<get_callback_map_t::iterator, bool> ret = mGetCallbacks.insert(std::pair<LLMaterialID, get_callback_t*>(material_id, new get_callback_t()));
237+
std::pair<get_callback_map_t::iterator, bool> ret = mGetCallbacks.emplace(material_id, std::make_unique<get_callback_t>());
238238
itCallback = ret.first;
239239
}
240240
connection = itCallback->second->connect(cb);;
@@ -279,7 +279,7 @@ boost::signals2::connection LLMaterialMgr::getTE(const LLUUID& region_id, const
279279
get_callback_te_map_t::iterator itCallback = mGetTECallbacks.find(te_mat_pair);
280280
if (itCallback == mGetTECallbacks.end())
281281
{
282-
std::pair<get_callback_te_map_t::iterator, bool> ret = mGetTECallbacks.insert(std::pair<TEMaterialPair, get_callback_te_t*>(te_mat_pair, new get_callback_te_t()));
282+
std::pair<get_callback_te_map_t::iterator, bool> ret = mGetTECallbacks.emplace(te_mat_pair, std::make_unique<get_callback_te_t>());
283283
itCallback = ret.first;
284284
}
285285
connection = itCallback->second->connect(cb);
@@ -317,7 +317,7 @@ boost::signals2::connection LLMaterialMgr::getAll(const LLUUID& region_id, LLMat
317317
getall_callback_map_t::iterator itCallback = mGetAllCallbacks.find(region_id);
318318
if (mGetAllCallbacks.end() == itCallback)
319319
{
320-
std::pair<getall_callback_map_t::iterator, bool> ret = mGetAllCallbacks.insert(std::pair<LLUUID, getall_callback_t*>(region_id, new getall_callback_t()));
320+
std::pair<getall_callback_map_t::iterator, bool> ret = mGetAllCallbacks.emplace(region_id, std::make_unique<getall_callback_t>());
321321
itCallback = ret.first;
322322
}
323323
return itCallback->second->connect(cb);;
@@ -329,8 +329,8 @@ void LLMaterialMgr::put(const LLUUID& object_id, const U8 te, const LLMaterial&
329329
if (mPutQueue.end() == itQueue)
330330
{
331331
LL_DEBUGS("Materials") << "mPutQueue insert object " << object_id << LL_ENDL;
332-
mPutQueue.insert(std::pair<LLUUID, facematerial_map_t>(object_id, facematerial_map_t()));
333-
itQueue = mPutQueue.find(object_id);
332+
auto ret = mPutQueue.emplace(object_id, facematerial_map_t());
333+
itQueue = ret.first;
334334
}
335335

336336
facematerial_map_t::iterator itFace = itQueue->second.find(te);
@@ -361,7 +361,7 @@ void LLMaterialMgr::setLocalMaterial(const LLUUID& region_id, LLMaterialPtr mate
361361
}
362362

363363
LL_DEBUGS("Materials") << "region " << region_id << "new local material id " << material_id << LL_ENDL;
364-
mMaterials.insert(std::pair<LLMaterialID, LLMaterialPtr>(material_id, material_ptr));
364+
mMaterials.emplace(material_id, material_ptr);
365365

366366
setMaterialCallbacks(material_id, material_ptr);
367367

@@ -376,7 +376,7 @@ const LLMaterialPtr LLMaterialMgr::setMaterial(const LLUUID& region_id, const LL
376376
{
377377
LL_DEBUGS("Materials") << "new material" << LL_ENDL;
378378
LLMaterialPtr newMaterial(new LLMaterial(material_data));
379-
std::pair<material_map_t::const_iterator, bool> ret = mMaterials.insert(std::pair<LLMaterialID, LLMaterialPtr>(material_id, newMaterial));
379+
std::pair<material_map_t::const_iterator, bool> ret = mMaterials.emplace(material_id, newMaterial);
380380
itMaterial = ret.first;
381381
}
382382

@@ -400,7 +400,6 @@ void LLMaterialMgr::setMaterialCallbacks(const LLMaterialID& material_id, const
400400
if (itCallbackTE != mGetTECallbacks.end())
401401
{
402402
(*itCallbackTE->second)(material_id, material_ptr, te_mat_pair.te);
403-
delete itCallbackTE->second;
404403
mGetTECallbacks.erase(itCallbackTE);
405404
}
406405
}
@@ -410,7 +409,6 @@ void LLMaterialMgr::setMaterialCallbacks(const LLMaterialID& material_id, const
410409
{
411410
(*itCallback->second)(material_id, material_ptr);
412411

413-
delete itCallback->second;
414412
mGetCallbacks.erase(itCallback);
415413
}
416414
}
@@ -509,7 +507,6 @@ void LLMaterialMgr::onGetAllResponse(bool success, const LLSD& content, const LL
509507
{
510508
(*itCallback->second)(region_id, materials);
511509

512-
delete itCallback->second;
513510
mGetAllCallbacks.erase(itCallback);
514511
}
515512

@@ -549,11 +546,11 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content)
549546
{
550547
llassert(response_data.isArray());
551548
LL_DEBUGS("Materials") << "response has "<< response_data.size() << " materials" << LL_ENDL;
549+
#ifdef SHOW_ASSERT // same condition that controls llassert()
552550
for (LLSD::array_const_iterator faceIter = response_data.beginArray(); faceIter != response_data.endArray(); ++faceIter)
553551
{
554-
# ifdef SHOW_ASSERT // same condition that controls llassert()
555552
const LLSD& face_data = *faceIter; // conditional to avoid unused variable warning
556-
# endif
553+
557554
llassert(face_data.isMap());
558555

559556
llassert(face_data.has(MATERIALS_CAP_OBJECT_ID_FIELD));
@@ -570,6 +567,7 @@ void LLMaterialMgr::onPutResponse(bool success, const LLSD& content)
570567

571568
// *TODO: do we really still need to process this?
572569
}
570+
#endif
573571
}
574572
}
575573

indra/newview/llmaterialmgr.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,13 @@ class LLMaterialMgr : public LLSingleton<LLMaterialMgr>
110110
typedef std::map<LLUUID, material_queue_t> get_queue_t;
111111
typedef std::pair<const LLUUID, LLMaterialID> pending_material_t;
112112
typedef std::map<const pending_material_t, F64> get_pending_map_t;
113-
typedef std::map<LLMaterialID, get_callback_t*> get_callback_map_t;
113+
typedef std::map<LLMaterialID, std::unique_ptr<get_callback_t>> get_callback_map_t;
114114

115115

116-
typedef boost::unordered_map<TEMaterialPair, get_callback_te_t*> get_callback_te_map_t;
116+
typedef boost::unordered_map<TEMaterialPair, std::unique_ptr<get_callback_te_t>> get_callback_te_map_t;
117117
typedef std::set<LLUUID> getall_queue_t;
118118
typedef std::map<LLUUID, F64> getall_pending_map_t;
119-
typedef std::map<LLUUID, getall_callback_t*> getall_callback_map_t;
119+
typedef std::map<LLUUID, std::unique_ptr<getall_callback_t>> getall_callback_map_t;
120120
typedef std::map<U8, LLMaterial> facematerial_map_t;
121121
typedef std::map<LLUUID, facematerial_map_t> put_queue_t;
122122

indra/newview/llpreviewgesture.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,9 @@ void LLPreviewGesture::saveIfNeeded()
10961096
if (!region)
10971097
{
10981098
LL_WARNS() << "Not connected to a region, cannot save gesture." << LL_ENDL;
1099+
// we're done with this gesture
1100+
delete gesture;
1101+
gesture = NULL;
10991102
return;
11001103
}
11011104
std::string agent_url = region->getCapability("UpdateGestureAgentInventory");

indra/newview/llvovolume.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,10 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
784784
for (S32 i = 0; i < num_faces; i++)
785785
{
786786
LLFace* face = mDrawable->getFace(i);
787-
if (!face) continue;
787+
if (!face || face->mExtents[0].equals3(face->mExtents[1])) continue;
788788
const LLTextureEntry *te = face->getTextureEntry();
789+
if (!te) continue;
790+
789791
LLViewerTexture *imagep = nullptr;
790792
U32 ch_min;
791793
U32 ch_max;
@@ -804,8 +806,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced)
804806
// Get _a_ non-null texture if possible (usually diffuse/basecolor, but could be something else)
805807
imagep = face->getTexture(ch);
806808
}
807-
if (!imagep || !te ||
808-
face->mExtents[0].equals3(face->mExtents[1]))
809+
if (!imagep)
809810
{
810811
continue;
811812
}

0 commit comments

Comments
 (0)