From 5cc44523f79b6cf495d2649fce9bf9e5181787e8 Mon Sep 17 00:00:00 2001
From: Aaron Brashears <aaronb@lindenlab.com>
Date: Fri, 9 Feb 2007 23:35:12 +0000
Subject: [PATCH] Result of svn merge -r57350:57790
 svn+ssh://svn/svn/linden/branches/os-patches.001 into release.

---
 doc/contributions.txt                         | 21 +++++
 indra/llcommon/llevent.cpp                    | 10 +-
 indra/llcommon/llevent.h                      |  1 +
 indra/llcommon/llsd.cpp                       |  4 +-
 indra/llcommon/llstring.cpp                   |  1 +
 indra/llmath/lloctree.h                       | 11 +--
 indra/llmessage/message.cpp                   | 14 ++-
 indra/llrender/llfontgl.cpp                   |  2 +-
 indra/llui/llfloater.cpp                      | 63 +++++++++----
 indra/llui/llscrolllistctrl.cpp               |  2 +-
 indra/llvfs/llvfs.cpp                         | 92 ++++++++++++-------
 indra/llwindow/llmousehandler.h               |  2 +
 indra/llxml/llxmlnode.cpp                     |  4 +-
 .../lscript_execute/lscript_execute.cpp       | 72 ++++++++++-----
 .../lscript/lscript_library/lscript_alloc.cpp | 51 +---------
 .../lscript_library/lscript_library.cpp       |  2 +-
 indra/newview/llcurrencyuimanager.cpp         | 16 ++--
 indra/newview/llfloateravatartextures.cpp     |  4 +-
 indra/newview/llfloaterbuyland.cpp            | 27 ++++--
 indra/newview/llfloaterfriends.cpp            |  3 +-
 indra/newview/llfloatergodtools.cpp           |  2 +-
 indra/newview/llfloaterregioninfo.cpp         |  2 +-
 indra/newview/llfloatertopobjects.cpp         |  2 +-
 indra/newview/llpanelclassified.cpp           |  2 +-
 indra/newview/llpanelgroupgeneral.cpp         |  2 +-
 indra/newview/llpanelgroupnotices.cpp         |  2 +-
 indra/newview/llpanelpick.cpp                 |  2 +-
 indra/newview/llselectmgr.cpp                 | 10 +-
 indra/newview/lltexturectrl.cpp               |  3 +-
 indra/newview/lltooldraganddrop.cpp           |  1 +
 indra/newview/llviewermenu.cpp                |  8 +-
 indra/newview/llviewermessage.cpp             | 14 ++-
 indra/newview/llviewerparcelmgr.cpp           |  7 +-
 indra/newview/llvoavatar.cpp                  | 23 +++--
 indra/test/llhttpclient_tut.cpp               |  2 +-
 indra/test/llpipeutil.cpp                     |  2 +
 indra/test/llsd_new_tut.cpp                   |  1 +
 indra/test/lltut.cpp                          |  1 +
 38 files changed, 296 insertions(+), 192 deletions(-)
 create mode 100644 doc/contributions.txt

diff --git a/doc/contributions.txt b/doc/contributions.txt
new file mode 100644
index 00000000000..8842a9a903e
--- /dev/null
+++ b/doc/contributions.txt
@@ -0,0 +1,21 @@
+Linden Lab would like to acknowledge source code contributions from the
+following residents.   The Second Life resident name is given below,
+along with the issue identifier corresponding to the patches we've
+received from them.  To see more about these contributions, visit
+http://jira.secondlife.com/ , and enter the issue identifier.
+
+Alissa Sabre - VWR-81, VWR-86
+blino Nakamura - VWR-17
+Drewan Keats - VWR-28
+Dylan Haskell - VWR-72
+Eddy Stryker - VWR-15, VWR-23
+Joghert LeSabre - VWR-64
+Kage Pixel - VWR-11
+Kunnis Basiat - VWR-82
+Paul Churchill - VWR-20
+Paula Innis - VWR-30
+Peekay Semyorka - VWR-7, VWR-19, VWR-49
+SpacedOut Frye - VWR-57
+Strife Onizuka - VWR-74, VWR-85, SVC-9
+Zipherius Turas - VWR-76, VWR-77
+
diff --git a/indra/llcommon/llevent.cpp b/indra/llcommon/llevent.cpp
index 6e6fce6ec3d..368159ee547 100644
--- a/indra/llcommon/llevent.cpp
+++ b/indra/llcommon/llevent.cpp
@@ -167,16 +167,14 @@ void LLSimpleDispatcher::addListener(LLEventListener* listener, LLSD filter, con
 
 void LLSimpleDispatcher::removeListener(LLEventListener* listener)
 {
-	std::vector<LLListenerEntry>::iterator itor;
-	for (itor=mListeners.begin(); itor!=mListeners.end();)
+	std::vector<LLListenerEntry>::iterator itor = mListeners.begin();
+	std::vector<LLListenerEntry>::iterator end = mListeners.end();
+	for (; itor != end; ++itor)
 	{
 		if ((*itor).listener == listener)
 		{
 			mListeners.erase(itor);
-		}
-		else
-		{
-			++itor;
+			break;
 		}
 	}
 	listener->handleDetach(mParent);
diff --git a/indra/llcommon/llevent.h b/indra/llcommon/llevent.h
index 4a619ba16f3..283f40f923d 100644
--- a/indra/llcommon/llevent.h
+++ b/indra/llcommon/llevent.h
@@ -109,6 +109,7 @@ class LLEventDispatcher : public LLThreadSafeRefCount
 
 	// Adds a listener to this dispatcher, with a given user data
 	// that will be passed to the listener when an event is fired.
+	// Duplicate pointers are removed on addtion.
 	void addListener(LLEventListener *listener, LLSD filter, const LLSD& userdata);
 
 	// Removes a listener from this dispatcher
diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp
index aa4cba99d1a..e5f366c4a41 100644
--- a/indra/llcommon/llsd.cpp
+++ b/indra/llcommon/llsd.cpp
@@ -10,6 +10,8 @@
 
 #include <sstream>
 #include <math.h>
+
+#include "llerror.h"
 #include "../llmath/llmath.h"
 #include "llformat.h"
 
@@ -234,7 +236,7 @@ namespace {
 	public:
 		ImplUUID(const LLSD::UUID& v) : Base(v) { }
 				
-		virtual LLSD::String	asString() const{ return mValue.getString(); }
+		virtual LLSD::String	asString() const{ return mValue.asString(); }
 		virtual LLSD::UUID		asUUID() const	{ return mValue; }
 	};
 
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index 50fd881ad76..767a72dfe92 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -176,6 +176,7 @@ llutf16string utf8str_to_utf16str ( const LLString& utf8str )
 LLWString utf16str_to_wstring(const llutf16string &utf16str, S32 len)
 {
 	LLWString wout;
+	if((len <= 0) || utf16str.empty()) return wout;
 
 	S32 i = 0;
 	// craziness to make gcc happy (llutf16string.c_str() is tweaked on linux):
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index 69ff43452c8..bea21e22c64 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -170,17 +170,10 @@ class LLOctreeNode : public LLTreeNode<T>
 
 	static void pushCenter(LLVector3d &center, LLVector3d &size, T* data)
 	{
-		LLVector3 pos(data->getPositionGroup());
-		F64 p[] =
-		{
-			(F64) pos.mV[0],
-			(F64) pos.mV[1],
-			(F64) pos.mV[2]
-		};
-			
+		LLVector3d pos(data->getPositionGroup());
 		for (U32 i = 0; i < 3; i++)
 		{
-			if (p[i] > center.mdV[i])
+			if (pos.mdV[i] > center.mdV[i])
 			{
 				center.mdV[i] += size.mdV[i];
 			}
diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp
index 9e1a0ee12cc..ec2f0cd20a4 100644
--- a/indra/llmessage/message.cpp
+++ b/indra/llmessage/message.cpp
@@ -5536,13 +5536,21 @@ void LLMessageSystem::getUUID(const char *block, const char *var, LLUUID &u, S32
 	getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), u.mData, sizeof(u.mData), blocknum);
 }
 
-bool LLMessageSystem::generateDigestForNumberAndUUIDs(char* digest, const U32 number, const LLUUID &id1, const LLUUID &id2) const
+bool LLMessageSystem::generateDigestForNumberAndUUIDs(
+	char* digest,
+	const U32 number,
+	const LLUUID& id1,
+	const LLUUID& id2) const
 {
+	// *NOTE: This method is needlessly inefficient. Instead of
+	// calling LLUUID::asString, it should just call
+	// LLUUID::toString().
+
 	const char *colon = ":";
 	char tbuf[16];	/* Flawfinder: ignore */ 
 	LLMD5 d;
-	LLString id1string = id1.getString();
-	LLString id2string = id2.getString();
+	std::string id1string = id1.asString();
+	std::string id2string = id2.asString();
 	std::string shared_secret = get_shared_secret();
 	unsigned char * secret = (unsigned char*)shared_secret.c_str();
 	unsigned char * id1str = (unsigned char*)id1string.c_str();
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index 05163c0782d..7c0289b5807 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -1311,7 +1311,7 @@ LLString LLFontGL::nameFromFont(const LLFontGL* fontp)
 {
 	if (fontp == sSansSerifHuge)
 	{
-		return LLString("SansSerifHude");
+		return LLString("SansSerifHuge");
 	}
 	else if (fontp == sSansSerifSmall)
 	{
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index f6eb1e8bf83..5d4711ef108 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -765,8 +765,6 @@ void LLFloater::setMinimized(BOOL minimize)
 
 	if (minimize)
 	{
-		mMinimized = TRUE;
-
 		mPreviousRect = mRect;
 
 		reshape( MINIMIZED_WIDTH, LLFLOATER_HEADER_SIZE, TRUE);
@@ -812,6 +810,8 @@ void LLFloater::setMinimized(BOOL minimize)
 			++dependent_it;
 		}
 
+		mMinimized = TRUE;
+
 		// Lose keyboard focus when minimized
 		releaseFocus();
 	}
@@ -2000,23 +2000,52 @@ void LLFloaterView::focusFrontFloater()
 
 void LLFloaterView::getMinimizePosition(S32 *left, S32 *bottom)
 {
-	// count the number of minimized children
-	S32 count = 0;
-	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-	{
-		LLView* viewp = *child_it;
-		LLFloater *floater = (LLFloater *)viewp;
-		if (floater->isMinimized())
-		{
-			count++;
-		}
+	S32 col = 0;
+	LLRect snap_rect_local = getSnapRect();
+	snap_rect_local.translate(-mRect.mLeft, -mRect.mBottom);
+	for(S32 row = snap_rect_local.mBottom;
+		row < snap_rect_local.getHeight() - LLFLOATER_HEADER_SIZE;
+		row += LLFLOATER_HEADER_SIZE ) //loop rows
+	{
+		for(col = snap_rect_local.mLeft;
+			col < snap_rect_local.getWidth() - MINIMIZED_WIDTH;
+			col += MINIMIZED_WIDTH)
+		{
+			bool foundGap = TRUE;
+			for(child_list_const_iter_t child_it = getChildList()->begin();
+				child_it != getChildList()->end();
+				++child_it) //loop floaters
+			{
+				// Examine minimized children.
+				LLFloater* floater = (LLFloater*)((LLView*)*child_it);
+				if(floater->isMinimized()) 
+				{
+					LLRect r = floater->getRect();
+					if((r.mBottom < (row + LLFLOATER_HEADER_SIZE))
+					   && (r.mBottom > (row - LLFLOATER_HEADER_SIZE))
+					   && (r.mLeft < (col + MINIMIZED_WIDTH))
+					   && (r.mLeft > (col - MINIMIZED_WIDTH)))
+					{
+						// needs the check for off grid. can't drag,
+						// but window resize makes them off
+						foundGap = FALSE;
+						break;
+					}
+				}
+			} //done floaters
+			if(foundGap)
+			{
+				*left = col;
+				*bottom = row;
+				return; //done
+			}
+		} //done this col
 	}
 
-	// space over for that many and up if necessary
-	S32 tiles_per_row = mRect.getWidth() / MINIMIZED_WIDTH;
-
-	*left = (count % tiles_per_row) * MINIMIZED_WIDTH;
-	*bottom = (count / tiles_per_row) * LLFLOATER_HEADER_SIZE;
+	// crude - stack'em all at 0,0 when screen is full of minimized
+	// floaters.
+	*left = snap_rect_local.mLeft;
+	*bottom = snap_rect_local.mBottom;
 }
 
 
diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp
index d263c25c722..2b7cbe5cef2 100644
--- a/indra/llui/llscrolllistctrl.cpp
+++ b/indra/llui/llscrolllistctrl.cpp
@@ -76,7 +76,7 @@ struct SortScrollListItem
 // LLScrollListIcon
 //
 LLScrollListIcon::LLScrollListIcon(LLImageGL* icon, S32 width, LLUUID image_id) :
-mIcon(icon), mImageUUID(image_id.getString())
+mIcon(icon), mImageUUID(image_id.asString())
 {
 	if (width)
 	{
diff --git a/indra/llvfs/llvfs.cpp b/indra/llvfs/llvfs.cpp
index f907fcab451..592f74dd025 100644
--- a/indra/llvfs/llvfs.cpp
+++ b/indra/llvfs/llvfs.cpp
@@ -44,12 +44,11 @@ class LLVFSBlock
 		mLength = size;
 	}
     
-	static BOOL insertFirstLL(LLVFSBlock *first, LLVFSBlock *second)
+	static bool locationSortPredicate(
+		const LLVFSBlock* lhs,
+		const LLVFSBlock* rhs)
 	{
-		return first->mLocation != second->mLocation
-			? first->mLocation < second->mLocation
-			: first->mLength < second->mLength;
-
+		return lhs->mLocation < rhs->mLocation;
 	}
 
 public:
@@ -362,9 +361,8 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r
     
 		U8 *tmp_ptr = buffer;
     
-		LLLinkedList<LLVFSBlock> files_by_loc;
-   		files_by_loc.setInsertBefore(LLVFSBlock::insertFirstLL);
-
+		std::vector<LLVFSFileBlock*> files_by_loc;
+		
 		while (tmp_ptr < buffer + fbuf.st_size)
 		{
 			LLVFSFileBlock *block = new LLVFSFileBlock();
@@ -384,7 +382,7 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r
 				block->mFileType < LLAssetType::AT_COUNT)
 			{
 				mFileBlocks.insert(fileblock_map::value_type(*block, block));
-				files_by_loc.addDataSorted(block);
+				files_by_loc.push_back(block);
 			}
 			else
 			if (block->mLength && block->mSize > 0)
@@ -420,22 +418,40 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r
 			tmp_ptr += block->SERIAL_SIZE;
 		}
 		delete[] buffer;
-    
-		// discover all the free blocks
-		LLVFSFileBlock *last_file_block = (LLVFSFileBlock*)files_by_loc.getFirstData();
-    
-		if (last_file_block)
+
+		std::sort(
+			files_by_loc.begin(),
+			files_by_loc.end(),
+			LLVFSFileBlock::locationSortPredicate);
+
+		// There are 3 cases that have to be considered.
+		// 1. No blocks
+		// 2. One block.
+		// 3. Two or more blocks.
+		if (!files_by_loc.empty())
 		{
-			// check for empty space at the beginning
+			// cur walks through the list.
+			std::vector<LLVFSFileBlock*>::iterator cur = files_by_loc.begin();
+			std::vector<LLVFSFileBlock*>::iterator end = files_by_loc.end();
+			LLVFSFileBlock* last_file_block = *cur;
+			
+			// Check to see if there is an empty space before the first file.
 			if (last_file_block->mLocation > 0)
 			{
-				LLVFSBlock *block = new LLVFSBlock(0, last_file_block->mLocation);
-				addFreeBlock(block);
+				// If so, create a free block.
+				addFreeBlock(new LLVFSBlock(0, last_file_block->mLocation));
 			}
-    
-			LLVFSFileBlock *cur_file_block;
-			while ((cur_file_block = (LLVFSFileBlock*)files_by_loc.getNextData()))
+
+			// Walk through the 2nd+ block.  If there is a free space
+			// between cur_file_block and last_file_block, add it to
+			// the free space collection.  This block will not need to
+			// run in the case there is only one entry in the VFS.
+			++cur;
+			while( cur != end )
 			{
+				LLVFSFileBlock* cur_file_block = *cur;
+
+				// Dupe check on the block
 				if (cur_file_block->mLocation == last_file_block->mLocation
 					&& cur_file_block->mLength == last_file_block->mLength)
 				{
@@ -452,21 +468,29 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r
 					if (cur_file_block->mLength > 0)
 					{
 						// convert to hole
-						LLVFSBlock* block = new LLVFSBlock(cur_file_block->mLocation,
-														   cur_file_block->mLength);
-						addFreeBlock(block);
+						addFreeBlock(
+							new LLVFSBlock(
+								cur_file_block->mLocation,
+								cur_file_block->mLength));
 					}
 					lockData();						// needed for sync()
 					sync(cur_file_block, TRUE);		// remove first on disk
 					sync(last_file_block, TRUE);	// remove last on disk
 					unlockData();					// needed for sync()
 					last_file_block = cur_file_block;
+					++cur;
 					continue;
 				}
 
-				U32 loc = last_file_block->mLocation + last_file_block->mLength;
+				// Figure out where the last block ended.
+				U32 loc = last_file_block->mLocation+last_file_block->mLength;
+
+				// Figure out how much space there is between where
+				// the last block ended and this block begins.
 				S32 length = cur_file_block->mLocation - loc;
     
+				// Check for more errors...  Seeing if the current
+				// entry and the last entry make sense together.
 				if (length < 0 || loc < 0 || loc > data_size)
 				{
 					// Invalid VFS
@@ -488,27 +512,25 @@ LLVFS::LLVFS(const char *index_filename, const char *data_filename, const BOOL r
 					return;
 				}
 
+				// we don't want to add empty blocks to the list...
 				if (length > 0)
 				{
-					LLVFSBlock *block = new LLVFSBlock(loc, length);
-					addFreeBlock(block);
+					addFreeBlock(new LLVFSBlock(loc, length));
 				}
-    
 				last_file_block = cur_file_block;
+				++cur;
 			}
     
 			// also note any empty space at the end
 			U32 loc = last_file_block->mLocation + last_file_block->mLength;
 			if (loc < data_size)
 			{
-				LLVFSBlock *block = new LLVFSBlock(loc, data_size - loc);
-				addFreeBlock(block);
+				addFreeBlock(new LLVFSBlock(loc, data_size - loc));
 			}
 		}
-		else
+		else // There where no blocks in the file.
 		{
-			LLVFSBlock *first_block = new LLVFSBlock(0, data_size);
-			addFreeBlock(first_block);
+			addFreeBlock(new LLVFSBlock(0, data_size));
 		}
 	}
 	else
@@ -1241,6 +1263,7 @@ void LLVFS::eraseBlockLength(LLVFSBlock *block)
 	S32 length = block->mLength;
 	blocks_length_map_t::iterator iter = mFreeBlocksByLength.lower_bound(length);
 	blocks_length_map_t::iterator end = mFreeBlocksByLength.end();
+	bool found_block = false;
 	while(iter != end)
 	{
 		LLVFSBlock *tblock = iter->second;
@@ -1248,11 +1271,12 @@ void LLVFS::eraseBlockLength(LLVFSBlock *block)
 		if (tblock == block)
 		{
 			mFreeBlocksByLength.erase(iter);
+			found_block = true;
 			break;
 		}
 		++iter;
 	}
-	if (iter == end)
+	if(!found_block)
 	{
 		llwarns << "eraseBlock could not find block" << llendl;
 	}
@@ -2044,7 +2068,7 @@ void LLVFS::dumpFiles()
 			lockData();
 			
 			LLString extension = get_extension(type);
-			LLString filename = id.getString() + extension;
+			LLString filename = id.asString() + extension;
 			llinfos << " Writing " << filename << llendl;
 			apr_file_t* file = ll_apr_file_open(filename, LL_APR_WB);
 			ll_apr_file_write(file, buffer, size);
diff --git a/indra/llwindow/llmousehandler.h b/indra/llwindow/llmousehandler.h
index cdde2ce0e01..e59b5845b0c 100644
--- a/indra/llwindow/llmousehandler.h
+++ b/indra/llwindow/llmousehandler.h
@@ -9,6 +9,8 @@
 #ifndef LL_MOUSEHANDLER_H
 #define LL_MOUSEHANDLER_H
 
+#include "llstring.h"
+
 // Abstract interface.
 // Intended for use via multiple inheritance. 
 // A class may have as many interfaces as it likes, but never needs to inherit one more than once.
diff --git a/indra/llxml/llxmlnode.cpp b/indra/llxml/llxmlnode.cpp
index 0789ec68429..131fb7bb3c9 100644
--- a/indra/llxml/llxmlnode.cpp
+++ b/indra/llxml/llxmlnode.cpp
@@ -2275,7 +2275,7 @@ void LLXMLNode::setUUIDValue(U32 length, const LLUUID *array)
 	LLString new_value;
 	for (U32 pos=0; pos<length; ++pos)
 	{
-		new_value.append(array[pos].getString());
+		new_value.append(array[pos].asString());
 		if (pos < length-1) new_value.append(" ");
 	}
 
@@ -2877,7 +2877,7 @@ BOOL LLXMLNode::performUnitTest(LLString &error_buffer)
 		}
 		if (node_uuid_checksum != uuid_checksum)
 		{
-			error_buffer.append(llformat("ERROR Node %s: UUID checksum mismatch: read %s / calc %s.\n", mName->mString, node_uuid_checksum.getString().c_str(), uuid_checksum.getString().c_str()));
+			error_buffer.append(llformat("ERROR Node %s: UUID checksum mismatch: read %s / calc %s.\n", mName->mString, node_uuid_checksum.asString().c_str(), uuid_checksum.asString().c_str()));
 			return FALSE;
 		}
 	}
diff --git a/indra/lscript/lscript_execute/lscript_execute.cpp b/indra/lscript/lscript_execute/lscript_execute.cpp
index 1cbcdc2c58b..e56bfd337ca 100644
--- a/indra/lscript/lscript_execute/lscript_execute.cpp
+++ b/indra/lscript/lscript_execute/lscript_execute.cpp
@@ -2577,6 +2577,7 @@ BOOL run_jump(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
 	offset += arg;
 	return FALSE;
 }
+
 BOOL run_jumpif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
 {
 	if (b_print)
@@ -2629,8 +2630,10 @@ BOOL run_jumpif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
 	else if (type == LST_STRING)
 	{
 		S32 base_address = lscript_pop_int(buffer);
-	// this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
-	// and function clean up of ref counts isn't based on scope (a mistake, I know)
+		// this bit of nastiness is to get around that code paths to
+		// local variables can result in lack of initialization and
+		// function clean up of ref counts isn't based on scope (a
+		// mistake, I know)
 		S32 address = base_address + get_register(buffer, LREG_HR) - 1;
 		if (address)
 		{
@@ -2655,8 +2658,10 @@ BOOL run_jumpif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
 	else if (type == LST_KEY)
 	{
 		S32 base_address = lscript_pop_int(buffer);
-	// this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
-	// and function clean up of ref counts isn't based on scope (a mistake, I know)
+		// this bit of nastiness is to get around that code paths to
+		// local variables can result in lack of initialization and
+		// function clean up of ref counts isn't based on scope (a
+		// mistake, I know)
 		S32 address = base_address + get_register(buffer, LREG_HR) - 1;
 		if (address)
 		{
@@ -2672,26 +2677,34 @@ BOOL run_jumpif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
 				if (strlen(sdata))		/*Flawfinder: ignore*/
 				{
 					LLUUID id;
-					id.set(sdata);
-					if (id != LLUUID::null)
+					if (id.set(sdata) && id.notNull())
 						offset += arg;
 				}
 				delete [] sdata;
 			}
 			lsa_decrease_ref_count(buffer, base_address);
 		}
-		else if (type == LST_LIST)
+	}
+	else if (type == LST_LIST)
+	{
+		S32 base_address = lscript_pop_int(buffer);
+		S32 address = base_address + get_register(buffer, LREG_HR) - 1;
+		if (address)
 		{
-			S32 address = lscript_pop_int(buffer);
-			LLScriptLibData *list = lsa_get_data(buffer, address, TRUE);
-			if (list->getListLength())
+			if (safe_heap_check_address(buffer, address + SIZEOF_SCRIPT_ALLOC_ENTRY, 1))
 			{
-				offset += arg;
+				LLScriptLibData *list = lsa_get_list_ptr(buffer, base_address, TRUE);
+				if (list && list->getListLength())
+				{
+					offset += arg;
+				}
+				delete list;
 			}
 		}
 	}
 	return FALSE;
 }
+
 BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
 {
 	if (b_print)
@@ -2744,8 +2757,10 @@ BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
 	else if (type == LST_STRING)
 	{
 		S32 base_address = lscript_pop_int(buffer);
-	// this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
-	// and function clean up of ref counts isn't based on scope (a mistake, I know)
+		// this bit of nastiness is to get around that code paths to
+		// local variables can result in lack of initialization and
+		// function clean up of ref counts isn't based on scope (a
+		// mistake, I know)
 		S32 address = base_address + get_register(buffer, LREG_HR) - 1;
 		if (address)
 		{
@@ -2770,8 +2785,10 @@ BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
 	else if (type == LST_KEY)
 	{
 		S32 base_address = lscript_pop_int(buffer);
-	// this bit of nastiness is to get around that code paths to local variables can result in lack of initialization
-	// and function clean up of ref counts isn't based on scope (a mistake, I know)
+		// this bit of nastiness is to get around that code paths to
+		// local variables can result in lack of initialization and
+		// function clean up of ref counts isn't based on scope (a
+		// mistake, I know)
 		S32 address = base_address + get_register(buffer, LREG_HR) - 1;
 		if (address)
 		{
@@ -2787,8 +2804,7 @@ BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
 				if (strlen(sdata))		/*Flawfinder: ignore*/
 				{
 					LLUUID id;
-					id.set(sdata);
-					if (id == LLUUID::null)
+					if (!id.set(sdata) || id.isNull())
 						offset += arg;
 				}
 				else
@@ -2799,13 +2815,25 @@ BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id)
 			}
 			lsa_decrease_ref_count(buffer, base_address);
 		}
-		else if (type == LST_LIST)
+	}
+	else if (type == LST_LIST)
+	{
+		S32 base_address = lscript_pop_int(buffer);
+		// this bit of nastiness is to get around that code paths to
+		// local variables can result in lack of initialization and
+		// function clean up of ref counts isn't based on scope (a
+		// mistake, I know)
+		S32 address = base_address + get_register(buffer, LREG_HR) - 1;
+		if (address)
 		{
-			S32 address = lscript_pop_int(buffer);
-			LLScriptLibData *list = lsa_get_data(buffer, address, TRUE);
-			if (!list->getListLength())
+			if (safe_heap_check_address(buffer, address + SIZEOF_SCRIPT_ALLOC_ENTRY, 1))
 			{
-				offset += arg;
+				LLScriptLibData *list = lsa_get_list_ptr(buffer, base_address, TRUE);
+				if (!list || !list->getListLength())
+				{
+					offset += arg;
+				}
+				delete list;
 			}
 		}
 	}
diff --git a/indra/lscript/lscript_library/lscript_alloc.cpp b/indra/lscript/lscript_library/lscript_alloc.cpp
index f26fef6d772..d98af1ddf34 100644
--- a/indra/lscript/lscript_library/lscript_alloc.cpp
+++ b/indra/lscript/lscript_library/lscript_alloc.cpp
@@ -982,58 +982,9 @@ S32 lsa_cmp_lists(U8 *buffer, S32 offset1, S32 offset2)
 
 	S32 length1 = list1->getListLength();
 	S32 length2 = list2->getListLength();
-
-	if (length1 != length2)
-	{
-		return length1 - length2;
-	}
-
-	LLScriptLibData *runner1 = list1;
-	LLScriptLibData *runner2 = list2;
-
-	S32 count = 0;
-
-	while (runner1)
-	{
-		if (runner1->mType != runner2->mType)
-			return count;
-
-		switch(runner1->mType)
-		{
-		case LST_INTEGER:
-			if (runner1->mInteger != runner2->mInteger)
-				return count;
-			break;
-		case LST_FLOATINGPOINT:
-			if (runner1->mFP != runner2->mFP)
-				return count;
-			break;
-		case LST_KEY:
-			if (strcmp(runner1->mKey, runner2->mKey))
-				return count;
-			break;
-		case LST_STRING:
-			if (strcmp(runner1->mString, runner2->mString))
-				return count;
-			break;
-		case LST_VECTOR:
-			if (runner1->mVec != runner2->mVec)
-				return count;
-		case LST_QUATERNION:
-			if (runner1->mQuat != runner2->mQuat)
-				return count;
-			break;
-		default:
-			break;
-		}
-
-		runner1 = runner1->mListp;
-		runner2 = runner2->mListp;
-	}
-
 	delete list1;
 	delete list2;
-	return 0;
+	return length1 - length2;
 }
 
 
diff --git a/indra/lscript/lscript_library/lscript_library.cpp b/indra/lscript/lscript_library/lscript_library.cpp
index eef3621d471..c0472926df7 100644
--- a/indra/lscript/lscript_library/lscript_library.cpp
+++ b/indra/lscript/lscript_library/lscript_library.cpp
@@ -100,7 +100,7 @@ void LLScriptLibrary::init()
 	addFunction(new LLScriptLibraryFunction(10.f, 0.2f, dummy_func, "llSetTexture", NULL, "si", "llSetTexture(string texture, integer face)\nsets the texture of face"));
 	addFunction(new LLScriptLibraryFunction(10.f, 0.2f, dummy_func, "llScaleTexture", NULL, "ffi", "llScaleTexture(float scales, float scalet, integer face)\nsets the texture s, t scales for the chosen face"));
 	addFunction(new LLScriptLibraryFunction(10.f, 0.2f, dummy_func, "llOffsetTexture", NULL, "ffi", "llOffsetTexture(float offsets, float offsett, integer face)\nsets the texture s, t offsets for the chosen face"));
-	addFunction(new LLScriptLibraryFunction(10.f, 0.2f, dummy_func, "llRotateTexture", NULL, "fi", "llOffsetTexture(float rotation, integer face)\nsets the texture rotation for the chosen face"));
+	addFunction(new LLScriptLibraryFunction(10.f, 0.2f, dummy_func, "llRotateTexture", NULL, "fi", "llRotateTexture(float rotation, integer face)\nsets the texture rotation for the chosen face"));
 	addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llGetTexture", "s", "i", "string llGetTexture(integer face)\ngets the texture of face (if it's a texture in the object inventory, otherwise the key in a string)"));
 	addFunction(new LLScriptLibraryFunction(10.f, 0.2f, dummy_func, "llSetPos", NULL, "v", "llSetPos(vector pos)\nsets the position (if the script isn't physical)"));
 	addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llGetPos", "v", NULL, "vector llGetPos()\ngets the position (if the script isn't physical)"));
diff --git a/indra/newview/llcurrencyuimanager.cpp b/indra/newview/llcurrencyuimanager.cpp
index ffea2928c20..96c7f709296 100644
--- a/indra/newview/llcurrencyuimanager.cpp
+++ b/indra/newview/llcurrencyuimanager.cpp
@@ -125,10 +125,10 @@ void LLCurrencyUIManager::Impl::updateCurrencyInfo()
 	}
 	
 	LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct();
-	keywordArgs.appendString("agentId",
-		gAgent.getID().getString());
-	keywordArgs.appendString("secureSessionId",
-		gAgent.getSecureSessionID().getString());
+	keywordArgs.appendString("agentId", gAgent.getID().asString());
+	keywordArgs.appendString(
+		"secureSessionId",
+		gAgent.getSecureSessionID().asString());
 	keywordArgs.appendInt("currencyBuy", mUserCurrencyBuy);
 	
 	LLXMLRPCValue params = LLXMLRPCValue::createArray();
@@ -172,10 +172,10 @@ void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password)
 	mCurrencyChanged = false;
 	
 	LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct();
-	keywordArgs.appendString("agentId",
-		gAgent.getID().getString());
-	keywordArgs.appendString("secureSessionId",
-		gAgent.getSecureSessionID().getString());
+	keywordArgs.appendString("agentId", gAgent.getID().asString());
+	keywordArgs.appendString(
+		"secureSessionId",
+		gAgent.getSecureSessionID().asString());
 	keywordArgs.appendInt("currencyBuy", mUserCurrencyBuy);
 	keywordArgs.appendInt("estimatedCost", mSiteCurrencyEstimatedCost);
 	keywordArgs.appendString("confirm", mSiteConfirm);
diff --git a/indra/newview/llfloateravatartextures.cpp b/indra/newview/llfloateravatartextures.cpp
index 76e096f0a39..293bf61a0d7 100644
--- a/indra/newview/llfloateravatartextures.cpp
+++ b/indra/newview/llfloateravatartextures.cpp
@@ -91,7 +91,7 @@ static void update_texture_ctrl(LLVOAvatar* avatarp,
 	else
 	{
 		ctrl->setImageAssetID(id);
-		ctrl->setToolTip(id.getString());
+		ctrl->setToolTip(id.asString());
 	}
 }
 
@@ -156,7 +156,7 @@ void LLFloaterAvatarTextures::refresh()
 	}
 	else
 	{
-		setTitle(mTitle + ": INVALID AVATAR (" + mID.getString() + ")");
+		setTitle(mTitle + ": INVALID AVATAR (" + mID.asString() + ")");
 	}
 #endif
 }
diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp
index 189c60132ee..c3b2ae70e78 100644
--- a/indra/newview/llfloaterbuyland.cpp
+++ b/indra/newview/llfloaterbuyland.cpp
@@ -406,7 +406,18 @@ void LLFloaterBuyLandUI::updateParcelInfo()
 	mParcelBillableArea =
 		llround(mRegion->getBillableFactor() * mParcelActualArea);
 
-	mParcelSupportedObjects = mParcel->getMaxPrimCapacity();
+ 	mParcelSupportedObjects = llround(
+		mParcel->getMaxPrimCapacity() * mParcel->getParcelPrimBonus()); 
+ 	// Can't have more than region max tasks, regardless of parcel 
+ 	// object bonus factor. 
+ 	LLViewerRegion* region = gParcelMgr->getSelectionRegion(); 
+ 	if(region) 
+ 	{ 
+		S32 max_tasks_per_region = (S32)region->getMaxTasks(); 
+		mParcelSupportedObjects = llmin(
+			mParcelSupportedObjects, max_tasks_per_region); 
+ 	} 
+
 	mParcelSoldWithObjects = mParcel->getSellWithObjects();
 	
 	LLVector3 center = mParcel->getCenterpoint();
@@ -665,9 +676,10 @@ void LLFloaterBuyLandUI::updateWebSiteInfo()
 #endif
 	
 	LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct();
-	keywordArgs.appendString("agentId", gAgent.getID().getString());
-	keywordArgs.appendString("secureSessionId",
-		gAgent.getSecureSessionID().getString());
+	keywordArgs.appendString("agentId", gAgent.getID().asString());
+	keywordArgs.appendString(
+		"secureSessionId",
+		gAgent.getSecureSessionID().asString());
 	keywordArgs.appendInt("billableArea", mPreflightAskBillableArea);
 	keywordArgs.appendInt("currencyBuy", mPreflightAskCurrencyBuy);
 	
@@ -752,9 +764,10 @@ void LLFloaterBuyLandUI::runWebSitePrep(const std::string& password)
 	}
 	
 	LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct();
-	keywordArgs.appendString("agentId", gAgent.getID().getString());
-	keywordArgs.appendString("secureSessionId",
-		gAgent.getSecureSessionID().getString());
+	keywordArgs.appendString("agentId", gAgent.getID().asString());
+	keywordArgs.appendString(
+		"secureSessionId",
+		gAgent.getSecureSessionID().asString());
 	keywordArgs.appendString("levelId", newLevel);
 	keywordArgs.appendInt("billableArea",
 		mIsForGroup ? 0 : mParcelBillableArea);
diff --git a/indra/newview/llfloaterfriends.cpp b/indra/newview/llfloaterfriends.cpp
index a910e1a12a6..6f31cbb3a05 100644
--- a/indra/newview/llfloaterfriends.cpp
+++ b/indra/newview/llfloaterfriends.cpp
@@ -518,8 +518,7 @@ void LLFloaterFriends::requestFriendship(const LLUUID& target_id, const LLString
 {
 	// HACK: folder id stored as "message"
 	LLUUID calling_card_folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_CALLINGCARD);
-	std::string message = calling_card_folder_id.getString();
-
+	std::string message = calling_card_folder_id.asString();
 	send_improved_im(target_id,
 					 target_name.c_str(),
 					 message.c_str(),
diff --git a/indra/newview/llfloatergodtools.cpp b/indra/newview/llfloatergodtools.cpp
index 45cf356a528..7096f5dbf6d 100644
--- a/indra/newview/llfloatergodtools.cpp
+++ b/indra/newview/llfloatergodtools.cpp
@@ -971,7 +971,7 @@ void LLPanelGridTools::flushMapVisibilityCachesConfirm(S32 option, void* data)
 	msg->addString("Method", "refreshmapvisibility");
 	msg->addUUID("Invoice", LLUUID::null);
 	msg->nextBlock("ParamList");
-	msg->addString("Parameter", gAgent.getID().getString());
+	msg->addString("Parameter", gAgent.getID().asString());
 	gAgent.sendReliableMessage();
 }
 
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index 55b3ee185bf..2857339db3b 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -2627,7 +2627,7 @@ void LLPanelEstateCovenant::sendChangeCovenantID(const LLUUID &asset_id)
 		msg->addUUID("Invoice", LLFloaterRegionInfo::getLastInvoice());
 
 		msg->nextBlock("ParamList");
-		msg->addString("Parameter", getCovenantID().getString().c_str());
+		msg->addString("Parameter", getCovenantID().asString());
 		gAgent.sendReliableMessage();
 	}
 }
diff --git a/indra/newview/llfloatertopobjects.cpp b/indra/newview/llfloatertopobjects.cpp
index 8e248648800..90490f6f9b9 100644
--- a/indra/newview/llfloatertopobjects.cpp
+++ b/indra/newview/llfloatertopobjects.cpp
@@ -231,7 +231,7 @@ void LLFloaterTopObjects::updateSelectionInfo()
 	LLUUID object_id = list->getCurrentID();
 	if (object_id.isNull()) return;
 
-	LLString object_id_string = object_id.getString();
+	std::string object_id_string = object_id.asString();
 
 	childSetValue("id_editor", LLSD(object_id_string));
 	childSetValue("object_name_editor", list->getFirstSelected()->getColumn(1)->getText());
diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index 74600a262a3..3cd40828296 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -785,7 +785,7 @@ void LLPanelClassified::sendClassifiedClickMessage(const char* type)
 	// You're allowed to click on your own ads to reassure yourself
 	// that the system is working.
 	std::vector<std::string> strings;
-	strings.push_back(mClassifiedID.getString());
+	strings.push_back(mClassifiedID.asString());
 	strings.push_back(type);
 	LLUUID no_invoice;
 	send_generic_message("classifiedclick", strings, no_invoice);
diff --git a/indra/newview/llpanelgroupgeneral.cpp b/indra/newview/llpanelgroupgeneral.cpp
index 06a75989186..10db68d4483 100644
--- a/indra/newview/llpanelgroupgeneral.cpp
+++ b/indra/newview/llpanelgroupgeneral.cpp
@@ -433,7 +433,7 @@ bool LLPanelGroupGeneral::apply(LLString& mesg)
 	if (!gdatap)
 	{
 		mesg = "No group data found for group ";
-		mesg.append(mGroupID.getString());
+		mesg.append(mGroupID.asString());
 		return false;
 	}
 
diff --git a/indra/newview/llpanelgroupnotices.cpp b/indra/newview/llpanelgroupnotices.cpp
index 1cef8153b83..9f2d9cf909d 100644
--- a/indra/newview/llpanelgroupnotices.cpp
+++ b/indra/newview/llpanelgroupnotices.cpp
@@ -503,7 +503,7 @@ void LLPanelGroupNotices::onSelectNotice(LLUICtrl* ctrl, void* data)
 	msg->addUUID("GroupNoticeID",item->getUUID());
 	gAgent.sendReliableMessage();
 
-	lldebugs << "Item " << item->getUUID().getString().c_str() << " selected." << llendl;
+	lldebugs << "Item " << item->getUUID() << " selected." << llendl;
 }
 
 void LLPanelGroupNotices::showNotice(const char* subject,
diff --git a/indra/newview/llpanelpick.cpp b/indra/newview/llpanelpick.cpp
index 6c5dcc1f450..ab2a298a06c 100644
--- a/indra/newview/llpanelpick.cpp
+++ b/indra/newview/llpanelpick.cpp
@@ -488,7 +488,7 @@ void LLPanelPick::onCommitAny(LLUICtrl* ctrl, void* data)
 		else
 		{*/
 			LLTabContainerVertical* tab = (LLTabContainerVertical*)self->getParent();
-			tab->setCurrentTabName(self->mNameEditor->getText());
+			if(tab) tab->setCurrentTabName(self->mNameEditor->getText());
 		//}
 	}
 }
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 50f6d115bde..3ae4ba91077 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -6343,13 +6343,17 @@ void LLSelectNodeList::addNodeAtEnd(LLSelectNode *nodep)
 
 void LLSelectNodeList::removeNode(LLSelectNode *nodep)
 {
-	std::list<LLSelectNode*>::iterator iter;
-	for (iter = begin(); iter != end(); ++iter)
+	std::list<LLSelectNode*>::iterator iter = begin();
+	while(iter != end())
 	{
 		if ((*iter) == nodep)
 		{
 			mSelectNodeMap.erase(nodep->getObject());
-			erase(iter++);
+			iter = erase(iter);
+		}
+		else
+		{
+			++iter;
 		}
 	}
 }
diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp
index be33de3cca9..5eae8c2ff1e 100644
--- a/indra/newview/lltexturectrl.cpp
+++ b/indra/newview/lltexturectrl.cpp
@@ -319,7 +319,8 @@ void LLFloaterTexturePicker::updateImageStats()
 		}
 		if (gAgent.isGodlike())
 		{
-			LLString tstring = "Pick: " + mTexturep->getID().getString();
+			LLString tstring = "Pick: ";
+			tstring.append(mTexturep->getID().asString());
 			setTitle(tstring);
 		}
 	}
diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp
index ea1284117df..94b549b8e64 100644
--- a/indra/newview/lltooldraganddrop.cpp
+++ b/indra/newview/lltooldraganddrop.cpp
@@ -582,6 +582,7 @@ LLToolDragAndDrop::LLToolDragAndDrop()
 	 LLTool("draganddrop", NULL),
 	 mDragStartX(0),
 	 mDragStartY(0),
+	 mSource(SOURCE_AGENT),
 	 mCursor(UI_CURSOR_NO),
 	 mLastAccept(ACCEPT_NO),
 	 mDrop(FALSE),
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 49578b186d7..838bf68f3d0 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -2124,7 +2124,7 @@ class LLAvatarDebug : public view_listener_t
 		}
 		llinfos << "Dumping temporary asset data to simulator logs for avatar " << avatar->getID() << llendl;
 		std::vector<std::string> strings;
-		strings.push_back( avatar->getID().getString() );
+		strings.push_back(avatar->getID().asString());
 		LLUUID invoice;
 		send_generic_message("dumptempassetdata", strings, invoice);
 		LLFloaterAvatarTextures::show( avatar->getID() );
@@ -7431,7 +7431,7 @@ void handle_selected_texture_info(void*)
 			std::string image_id_string;
 			if (gAgent.isGodlike())
 			{
-				image_id_string = image_id.getString() + " ";
+				image_id_string = image_id.asString() + " ";
 			}
 			msg = llformat("%s%dx%d %s on face ",
 								image_id_string.c_str(),
@@ -8246,7 +8246,9 @@ BOOL LLViewerMenuHolderGL::hideMenus()
 	if (handled)
 	{
 		gSelectMgr->deselectTransient();
-		if (!gFloaterTools->getVisible() && !LLFloaterLand::floaterVisible())
+		if(!gFloaterTools->getVisible()
+		   && !LLFloaterLand::floaterVisible()
+		   && !LLFloaterBuyLand::isOpen()) 
 		{
 			gParcelMgr->deselectLand();	
 		}
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index 71e3b5dded5..f402fc320bb 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -1621,7 +1621,17 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 		}
 		break;
 	case IM_BUSY_AUTO_RESPONSE:
-		gIMView->addMessage(session_id, from_id, name, message);
+		// fix for JIRA issue VWR-20 submitted 13-JAN-2007 - Paul Churchill
+		if (is_muted)
+		{
+			lldebugs << "Ignoring busy response from " << from_id << llendl;
+			return;
+		}
+		else
+		{
+			// original code resumes
+			gIMView->addMessage(session_id, from_id, name, message);
+		}
 		break;
 		
 	case IM_LURE_USER:
@@ -1722,7 +1732,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
 			LLAvatarTracker::formFriendship(from_id);
 			
 			std::vector<std::string> strings;
-			strings.push_back( from_id.getString() );
+			strings.push_back(from_id.asString());
 			send_generic_message("requestonlinenotification", strings);
 			
 			args["[NAME]"] = name;
diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp
index a31708a6213..81576bd5fc0 100644
--- a/indra/newview/llviewerparcelmgr.cpp
+++ b/indra/newview/llviewerparcelmgr.cpp
@@ -698,9 +698,10 @@ BOOL LLViewerParcelMgr::agentCanBuild() const
 {
 	if (mAgentParcel)
 	{
-		return gAgent.isGodlike()
-			|| (mAgentParcel->getOwnerID() == gAgent.getID())
-			|| (mAgentParcel->getAllowModify());
+		return (gAgent.isGodlike()
+				|| (mAgentParcel->allowModifyBy(
+						gAgent.getID(),
+						gAgent.getGroupID())));
 	}
 	else
 	{
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index efcd36af0a9..b21df05afe1 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -2988,14 +2988,24 @@ void LLVOAvatar::updateCharacter(LLAgent &agent)
 			{
 				if (motionp->getMinPixelArea() < getPixelArea())
 				{
-					char output[256];		/* Flawfinder: ignore */
+					char output[MAX_STRING];	/* Flawfinder: ignore */
 					if (motionp->getName().empty())
 					{
-						snprintf(output, sizeof(output), "%s - %d", motionp->getID().getString().c_str(), (U32)motionp->getPriority());		/* Flawfinder: ignore */
+						snprintf( /* Flawfinder: ignore */
+							output,
+							MAX_STRING,
+							"%s - %d",
+							motionp->getID().asString().c_str(),
+							(U32)motionp->getPriority());
 					}
 					else
 					{
-						snprintf(output, sizeof(output), "%s - %d", motionp->getName().c_str(), (U32)motionp->getPriority());		/* Flawfinder: ignore */
+						snprintf(	/* Flawfinder: ignore */
+							output,
+							MAX_STRING,
+							"%s - %d",
+							motionp->getName().c_str(),
+							(U32)motionp->getPriority());
 					}
 					addDebugText(output);
 				}
@@ -3948,9 +3958,10 @@ void LLVOAvatar::updateTextures(LLAgent &agent)
 				&& imagep->getID() != IMG_DEFAULT_AVATAR
 				&& !imagep->getTargetHost().isOk())
 			{
-				llwarns << "LLVOAvatar::updateTextures No host for texture " << imagep->getID() 
-						<< " for avatar " << (mIsSelf ? "<myself>" : getID().getString()) 
-						<< " on host " << getRegion()->getHost() << llendl;
+				llwarns << "LLVOAvatar::updateTextures No host for texture "
+					<< imagep->getID() << " for avatar "
+					<< (mIsSelf ? "<myself>" : getID().asString().c_str()) 
+					<< " on host " << getRegion()->getHost() << llendl;
 			}
 			
 			switch( i )
diff --git a/indra/test/llhttpclient_tut.cpp b/indra/test/llhttpclient_tut.cpp
index 40cde1fd6c2..43ef6f44386 100644
--- a/indra/test/llhttpclient_tut.cpp
+++ b/indra/test/llhttpclient_tut.cpp
@@ -13,8 +13,8 @@
  */
 
 #include <tut/tut.h>
+#include "linden_common.h"
 #include "lltut.h"
-
 #include "llhttpclient.h"
 #include "llformat.h"
 #include "llpipeutil.h"
diff --git a/indra/test/llpipeutil.cpp b/indra/test/llpipeutil.cpp
index f4b1b28c1d0..773a9676816 100644
--- a/indra/test/llpipeutil.cpp
+++ b/indra/test/llpipeutil.cpp
@@ -7,6 +7,8 @@
  * $License$
  */
 
+
+#include "linden_common.h"
 #include "llpipeutil.h"
 
 #include <stdlib.h>
diff --git a/indra/test/llsd_new_tut.cpp b/indra/test/llsd_new_tut.cpp
index 6a38a1a8ea5..23546982395 100644
--- a/indra/test/llsd_new_tut.cpp
+++ b/indra/test/llsd_new_tut.cpp
@@ -9,6 +9,7 @@
 
 #include <math.h>
 #include <tut/tut.h>
+#include "linden_common.h"
 #include "lltut.h"
 
 #include "llsd.h"
diff --git a/indra/test/lltut.cpp b/indra/test/lltut.cpp
index 592d61137d3..5a6ccabec2f 100644
--- a/indra/test/lltut.cpp
+++ b/indra/test/lltut.cpp
@@ -8,6 +8,7 @@
  * $License$
  */
 
+#include "linden_common.h"
 #include "lltut.h"
 
 #include "llformat.h"
-- 
GitLab