App: [skip ci] fix memory leaks:
Found two memory leaks in class Enumeration * method tearDown() always ignored to free the memory of the first element * assignment operator didn't call tearDown() when needed
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user