fix for bad string.c_str() usage on temporary strings (seems to be problematic starting with gcc>=6.3.0, fixes #325 and #326)
This commit is contained in:
@@ -775,17 +775,18 @@ result_t ValueListDataField::readSymbols(const SymbolString& input, size_t offse
|
||||
result_t ValueListDataField::writeSymbols(size_t offset, istringstream* input,
|
||||
SymbolString* output, size_t* usedLength) const {
|
||||
const NumberDataType* numType = reinterpret_cast<const NumberDataType*>(m_dataType);
|
||||
if (isIgnored() || input->str() == nullptr_VALUE) {
|
||||
const string inputStr = input->str();
|
||||
if (isIgnored() || inputStr == nullptr_VALUE) {
|
||||
// replacement value
|
||||
return numType->writeRawValue(numType->getReplacement(), offset, m_length, output, usedLength);
|
||||
}
|
||||
|
||||
const char* str = input->str().c_str();
|
||||
for (map<unsigned int, string>::const_iterator it = m_values.begin(); it != m_values.end(); ++it) {
|
||||
if (it->second.compare(str) == 0) {
|
||||
if (it->second == inputStr) {
|
||||
return numType->writeRawValue(it->first, offset, m_length, output, usedLength);
|
||||
}
|
||||
}
|
||||
const char* str = inputStr.c_str();
|
||||
char* strEnd = nullptr; // fall back to raw value in input
|
||||
unsigned int value;
|
||||
value = (unsigned int)strtoul(str, &strEnd, 10);
|
||||
|
||||
Reference in New Issue
Block a user