From 620ee989e31c3b2921dbdab81a98038d387727cf Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Wed, 13 Jul 2022 22:51:29 +0300
Subject: [PATCH] SL-17772 Crash and a memory leak in
 LLPanelInventoryListItemBase

1. text_params, not text_aprams, due to this viewer was reusing same params and failing to create mTitleCtrl
2. All ctrls should be owned.
---
 indra/newview/llinventorylistitem.cpp | 32 ++++++++++++++++++---------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/indra/newview/llinventorylistitem.cpp b/indra/newview/llinventorylistitem.cpp
index 12bb609df8c..de6a850b570 100644
--- a/indra/newview/llinventorylistitem.cpp
+++ b/indra/newview/llinventorylistitem.cpp
@@ -298,31 +298,41 @@ LLPanelInventoryListItemBase::LLPanelInventoryListItemBase(LLViewerInventoryItem
 	applyXUILayout(icon_params, this);
 
 	mIconCtrl = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
-	if (mIconCtrl)
-	{
-		addChild(mIconCtrl);
-	}
-	else
+    if (!mIconCtrl)
 	{
 		LLIconCtrl::Params icon_params;
 		icon_params.name = "item_icon";
 		mIconCtrl = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
 	}
 
+    if (mIconCtrl)
+    {
+        addChild(mIconCtrl);
+    }
+    else
+    {
+        LL_ERRS() << "Failed to create mIconCtrl" << LL_ENDL;
+    }
+
 	LLTextBox::Params text_params(params.item_name);
 	applyXUILayout(text_params, this);
 
 	mTitleCtrl = LLUICtrlFactory::create<LLTextBox>(text_params);
-	if (mTitleCtrl)
+	if (!mTitleCtrl)
 	{
-		addChild(mTitleCtrl);
-	}
-	else
-	{
-		LLTextBox::Params text_aprams;
+		LLTextBox::Params text_params;
 		text_params.name = "item_title";
 		mTitleCtrl = LLUICtrlFactory::create<LLTextBox>(text_params);
 	}
+
+    if (mTitleCtrl)
+    {
+        addChild(mTitleCtrl);
+    }
+    else
+    {
+        LL_ERRS() << "Failed to create mTitleCtrl" << LL_ENDL;
+    }
 }
 
 class WidgetVisibilityChanger
-- 
GitLab