From 1f80dac4c0f5b3e3b2106f7113b157c2e02b2da9 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Tue, 24 Dec 2013 19:33:17 +0100 Subject: [PATCH] Don't cause undefined behavior by calling std::vector<>::front() for empty container. --- indra/newview/llagentwearablesfetch.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/indra/newview/llagentwearablesfetch.cpp b/indra/newview/llagentwearablesfetch.cpp index 3b48606a5..1dc9db79c 100644 --- a/indra/newview/llagentwearablesfetch.cpp +++ b/indra/newview/llagentwearablesfetch.cpp @@ -135,7 +135,15 @@ void LLInitialWearablesFetch::processContents() LLInventoryModel::cat_array_t cat_array; LLInventoryModel::item_array_t wearable_array; LLFindWearables is_wearable; - llassert(mComplete.size() != 0); + // + llassert(!mComplete.empty()); + if (mComplete.empty()) + { + // We can't call mComplete.front() in this case. + llwarns << "mComplete is empty." << llendl; + } + else + // gInventory.collectDescendentsIf(mComplete.front(), cat_array, wearable_array, LLInventoryModel::EXCLUDE_TRASH, is_wearable);