From ae17dad2f9ce773edb7314a85ab4a1a4ec9a4449 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Sat, 4 Mar 2017 11:30:07 +0200 Subject: [PATCH] Fix idStr self-assignment Was calling memcpy with overlapping parameters which is inefficient, undefined behavior and Valgrind complained about it. --- idlib/Str.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/idlib/Str.h b/idlib/Str.h index 3ac1cd6..70e6c9d 100644 --- a/idlib/Str.h +++ b/idlib/Str.h @@ -519,6 +519,10 @@ ID_INLINE char &idStr::operator[]( int index ) { #pragma GCC diagnostic pop ID_INLINE void idStr::operator=( const idStr &text ) { + if (&text == this) { + return; + } + int l; l = text.Length();