From 5e225213f6bdb7b4ca97abfef99b2249a1f88638 Mon Sep 17 00:00:00 2001
From: Stinson Linden <stinson@lindenlab.com>
Date: Wed, 23 Apr 2014 17:57:23 +0100
Subject: [PATCH] MAINT-4009: Adding an ares cleanup call to free the allocated
 memory.

---
 indra/llmessage/llares.cpp    | 9 +++++++++
 indra/llmessage/llares.h      | 1 +
 indra/newview/llappviewer.cpp | 3 +++
 3 files changed, 13 insertions(+)

diff --git a/indra/llmessage/llares.cpp b/indra/llmessage/llares.cpp
index 81e28121fd9..9f90ae15447 100755
--- a/indra/llmessage/llares.cpp
+++ b/indra/llmessage/llares.cpp
@@ -610,6 +610,15 @@ LLAres *ll_init_ares()
 	return gAres;
 }
 
+void ll_cleanup_ares()
+{
+	if (gAres != NULL)
+	{
+		delete gAres;
+		gAres = NULL;
+	}
+}
+
 LLDnsRecord::LLDnsRecord(LLResType type, const std::string &name,
 						 unsigned ttl)
 	: LLRefCount(),
diff --git a/indra/llmessage/llares.h b/indra/llmessage/llares.h
index 800781ee884..0b5d49e3227 100755
--- a/indra/llmessage/llares.h
+++ b/indra/llmessage/llares.h
@@ -578,5 +578,6 @@ extern LLAres *gAres;
  * thread safe.
  */
 extern LLAres *ll_init_ares();
+extern void ll_cleanup_ares();
 
 #endif // LL_LLARES_H
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 3b9259a9664..2b634074d59 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -2019,6 +2019,9 @@ bool LLAppViewer::cleanup()
 	// Non-LLCurl libcurl library
 	mAppCoreHttp.cleanup();
 
+	// NOTE The following call is not thread safe. 
+	ll_cleanup_ares();
+
 	LLFilePickerThread::cleanupClass();
 
 	//MUST happen AFTER LLCurl::cleanupClass
-- 
GitLab