Fix crash in enum property due to index out of range
This commit is contained in:
@@ -100,7 +100,9 @@ void Enumeration::setEnums(const char **plEnums)
|
||||
std::string oldValue;
|
||||
bool preserve = (isValid() && plEnums != NULL);
|
||||
if (preserve) {
|
||||
oldValue = getCStr();
|
||||
const char* str = getCStr();
|
||||
if (str)
|
||||
oldValue = str;
|
||||
}
|
||||
|
||||
// set _ownEnumArray
|
||||
@@ -126,7 +128,9 @@ void Enumeration::setEnums(const std::vector<std::string> &values)
|
||||
std::string oldValue;
|
||||
bool preserve = isValid();
|
||||
if (preserve) {
|
||||
oldValue = getCStr();
|
||||
const char* str = getCStr();
|
||||
if (str)
|
||||
oldValue = str;
|
||||
}
|
||||
|
||||
if (isValid() && _ownEnumArray) {
|
||||
@@ -165,7 +169,7 @@ void Enumeration::setValue(const char *value)
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int i = 0;
|
||||
int i = 0;
|
||||
const char **plEnums = _EnumArray;
|
||||
|
||||
// search for the right entry
|
||||
@@ -322,7 +326,10 @@ void Enumeration::findMaxVal(void)
|
||||
}
|
||||
|
||||
const char **plEnums = _EnumArray;
|
||||
long i = 0;
|
||||
|
||||
// the NULL terminator doesn't belong to the range of
|
||||
// valid values
|
||||
int i = -1;
|
||||
while (*(plEnums++) != NULL) {
|
||||
++i;
|
||||
// very unlikely to have enums with more then 5000 entries!
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace App
|
||||
/*!
|
||||
* Returns -1 if the enumeration is not valid according to isValid()
|
||||
*/
|
||||
int maxValue(void) const {return _maxVal;};
|
||||
int maxValue(void) const {return _maxVal;}
|
||||
|
||||
/// Assignment operator
|
||||
Enumeration & operator=(const Enumeration &other);
|
||||
@@ -161,7 +161,7 @@ namespace App
|
||||
bool operator==(const char *other) const;
|
||||
protected:
|
||||
/// Returns true if instance was not initialized via static string list
|
||||
bool isCustom(void) const {return _ownEnumArray;};
|
||||
bool isCustom(void) const {return _ownEnumArray;}
|
||||
|
||||
/// Updates _maxVal
|
||||
void findMaxVal(void);
|
||||
|
||||
Reference in New Issue
Block a user