From 6e5242f0a4e8a2e9cd9f21e89fae4870d1acceca Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Thu, 14 May 2020 08:50:39 -0400
Subject: [PATCH] DRTVWR-476: Fix LLError::Log::classname(T*) template
 function.

First, the signature classname(const T*) was wrong: that function could only
accept a pointer to const T. The expression classname(someptr) where someptr
was a pointer to non-const SomeType displayed "SomeType*" because it could
only match classname(const T&), where T was SomeType*.

classname(T* const) is what we should have written, meaning "const pointer to
T" rather than "pointer to const T."

Second, the previous implementation failed to handle the case in which the
pointer was nullptr.
---
 indra/llcommon/llerror.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h
index 3cdd051ac73..ffaa464d77a 100644
--- a/indra/llcommon/llerror.h
+++ b/indra/llcommon/llerror.h
@@ -207,7 +207,7 @@ namespace LLError
 		static std::string classname()             { return demangle(typeid(T).name()); }
 		/// classname(some_pointer)
 		template <typename T>
-		static std::string classname(const T* ptr) { return demangle(typeid(*ptr).name()); }
+		static std::string classname(T* const ptr) { return ptr? demangle(typeid(*ptr).name()) : "nullptr"; }
 		/// classname(some_reference)
 		template <typename T>
 		static std::string classname(const T& obj) { return demangle(typeid(obj).name()); }
-- 
GitLab