diff --git a/src/App/Enumeration.cpp b/src/App/Enumeration.cpp index f9a346c55c..bda0899206 100644 --- a/src/App/Enumeration.cpp +++ b/src/App/Enumeration.cpp @@ -84,8 +84,8 @@ void Enumeration::tearDown(void) char **plEnums = (char **)_EnumArray; // Delete C Strings first - while (*(plEnums++) != NULL) { - free(*plEnums); + while (*plEnums != NULL) { + free(*(plEnums++)); } delete [] _EnumArray; @@ -288,9 +288,16 @@ bool Enumeration::isValid(void) const Enumeration & Enumeration::operator=(const Enumeration &other) { + if (this == &other) + return *this; + if (other._ownEnumArray) { setEnums(other.getEnumVector()); } else { + if (isValid() && _ownEnumArray) { + tearDown(); + } + _EnumArray = other._EnumArray; }