diff --git a/nel/include/nel/misc/deep_ptr.h b/nel/include/nel/misc/deep_ptr.h
new file mode 100644
index 000000000..f0b5b1f79
--- /dev/null
+++ b/nel/include/nel/misc/deep_ptr.h
@@ -0,0 +1,72 @@
+// NeL - MMORPG Framework
+// Copyright (C) 2020 Jan BOON (Kaetemi)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+#ifndef NLMISC_DEEP_PTR_H
+#define NLMISC_DEEP_PTR_H
+
+#include
+
+namespace NLMISC {
+
+/// Pointer template with deep copy and move semantics
+template
+class CDeepPtr
+{
+public:
+ NL_FORCE_INLINE CDeepPtr() : m(NULL) { } //< Null
+ NL_FORCE_INLINE ~CDeepPtr() { delete m; }
+
+ NL_FORCE_INLINE CDeepPtr(const CDeepPtr &p) : m(p.m ? new T(*p) : NULL) { } //< Copy operator
+ NL_FORCE_INLINE CDeepPtr &operator=(const CDeepPtr &p) { if (p.m) { if (!m) m = new T(*p); else *m = *p; } else { delete m; m = NULL; } return *this; } //< Copy operator
+
+#ifdef NL_CPP14
+ NL_FORCE_INLINE CDeepPtr(CDeepPtr &&p) noexcept : m(p.m) { p.m = NULL; } //< Move operator
+ NL_FORCE_INLINE CDeepPtr &operator=(CDeepPtr &&p) noexcept { delete m; m = p.m; p.m = NULL; return *this; } //< Move operator
+#endif
+
+ NL_FORCE_INLINE CDeepPtr(T *p) : m(p) { } //< Initializer
+ NL_FORCE_INLINE CDeepPtr &operator=(T *p) { delete m; m = p; return *this; } //< Initializer
+
+ NL_FORCE_INLINE bool operator==(const CDeepPtr &p) const { return /* (m == p.m) || */ (m && p.m && *m == *p); }
+ NL_FORCE_INLINE bool operator!=(const CDeepPtr &p) const { return !(*this == p); }
+
+ NL_FORCE_INLINE bool operator==(const T *p) const { return (m == p) || (m && p && *m == *p); }
+ NL_FORCE_INLINE bool operator!=(const T *p) const { return !(*this == p); }
+
+ NL_FORCE_INLINE bool operator==(int p) const { return (*this == (const T *)(ptrdiff_t)p); } //< == 0
+ NL_FORCE_INLINE bool operator!=(int p) const { return (*this != (const T *)(ptrdiff_t)p); } //< != 0
+
+ NL_FORCE_INLINE T &operator*() { return *m; }
+ NL_FORCE_INLINE const T &operator*() const { return *m; }
+ NL_FORCE_INLINE T *operator->() { return m; }
+ NL_FORCE_INLINE const T *operator->() const { return m; }
+
+ NL_FORCE_INLINE operator bool() const { return m; }
+ NL_FORCE_INLINE bool operator!() const { return !m; }
+
+ NL_FORCE_INLINE T *ptr() { return m; }
+ NL_FORCE_INLINE const T *ptr() const { return m; }
+
+private:
+ T *m;
+
+};
+
+} /* namespace NLMISC */
+
+#endif /* #ifndef NLMISC_DEEP_PTR_H */
+
+/* end of file */
diff --git a/nel/src/misc/utf_string_view.cpp b/nel/src/misc/utf_string_view.cpp
index 283ef9555..8808930b4 100644
--- a/nel/src/misc/utf_string_view.cpp
+++ b/nel/src/misc/utf_string_view.cpp
@@ -287,6 +287,12 @@ u32char CUtfStringView::utf8Iterator(const void **addr)
// Replacement character �
return 0xFFFD;
}
+ else if (c0 < 0x10000)
+ {
+ // Invalid encoding
+ // Replacement character �
+ return 0xFFFD;
+ }
}
else
{
@@ -320,6 +326,12 @@ u32char CUtfStringView::utf8Iterator(const void **addr)
// Replacement character �
return 0xFFFD;
}
+ else if (c0 < 0x0800)
+ {
+ // Invalid encoding
+ // Replacement character �
+ return 0xFFFD;
+ }
}
else
{
@@ -327,6 +339,12 @@ u32char CUtfStringView::utf8Iterator(const void **addr)
return 0xFFFD;
}
}
+ else if (c0 < 0x80)
+ {
+ // Invalid encoding
+ // Replacement character �
+ return 0xFFFD;
+ }
}
else
{