From 7dc1e2eedbf29396b6614f8e7e39b7938dd5e301 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Wed, 27 Jan 2010 15:04:12 -0800
Subject: [PATCH] CID-195

Checker: RESOURCE_LEAK
Function: LLAgentWearables::addLocalTextureObject(EWearableType, LLVOAvatarDefines::ETextureIndex, unsigned int)
File: /indra/newview/llagentwearables.cpp
---
 indra/newview/llagentwearables.cpp | 3 ++-
 indra/newview/llwearable.cpp       | 4 ++--
 indra/newview/llwearable.h         | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 401d74c4efd..b0ff3a56261 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -1130,8 +1130,9 @@ void LLAgentWearables::addLocalTextureObject(const EWearableType wearable_type,
 	if (!wearable)
 	{
 		llerrs << "Tried to add local texture object to invalid wearable with type " << wearable_type << " and index " << wearable_index << llendl;
+		return;
 	}
-	LLLocalTextureObject* lto = new LLLocalTextureObject();
+	LLLocalTextureObject lto;
 	wearable->setLocalTextureObject(texture_type, lto);
 }
 
diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp
index b789bd3650a..8cfb8b11035 100644
--- a/indra/newview/llwearable.cpp
+++ b/indra/newview/llwearable.cpp
@@ -818,7 +818,7 @@ const LLLocalTextureObject* LLWearable::getConstLocalTextureObject(S32 index) co
 	return NULL;
 }
 
-void LLWearable::setLocalTextureObject(S32 index, LLLocalTextureObject *lto)
+void LLWearable::setLocalTextureObject(S32 index, LLLocalTextureObject &lto)
 {
 	if( mTEMap.find(index) != mTEMap.end() )
 	{
@@ -826,7 +826,7 @@ void LLWearable::setLocalTextureObject(S32 index, LLLocalTextureObject *lto)
 	}
 	if( lto )
 	{
-		mTEMap[index] = new LLLocalTextureObject(*lto);
+		mTEMap[index] = new LLLocalTextureObject(lto);
 	}
 }
 
diff --git a/indra/newview/llwearable.h b/indra/newview/llwearable.h
index 7a579b248e6..dae983bcf33 100644
--- a/indra/newview/llwearable.h
+++ b/indra/newview/llwearable.h
@@ -114,7 +114,7 @@ class LLWearable
 	LLLocalTextureObject* getLocalTextureObject(S32 index);
 	const LLLocalTextureObject* getConstLocalTextureObject(S32 index) const;
 
-	void				setLocalTextureObject(S32 index, LLLocalTextureObject *lto);
+	void				setLocalTextureObject(S32 index, LLLocalTextureObject &lto);
 	void				addVisualParam(LLVisualParam *param);
 	void				setVisualParams();
 	void 				setVisualParamWeight(S32 index, F32 value, BOOL upload_bake);
-- 
GitLab