Showing the changes to Source/Libraries/TimeSeriesPlatformLibrary/Data/DataRow.cpp (1 of 6 files). Show all
Unified · Split
| @@ -123,8 +123,8 @@ void DataRow::SetStringValue(int32_t index, const Nullable<string>& value) · 122 unmodified lines | |||
| 123 | if (value.HasValue()) | 123 | if (value.HasValue()) |
| 124 | { | 124 | { |
| 125 | const string& strval = value.GetValueOrDefault(); | 125 | const string& strval = value.GetValueOrDefault(); |
| 126 | const int32_t length = strval.size(); | 126 | const int32_t length = strval.size() + 1; |
| 127 | char* copy = static_cast<char*>(malloc(length + 1)); | 127 | char* copy = static_cast<char*>(malloc(length * sizeof(char))); |
| 128 | strcpy_s(copy, length, strval.c_str()); | 128 | strcpy_s(copy, length, strval.c_str()); |
| 129 | m_values[index] = copy; | 129 | m_values[index] = copy; |
| 130 | } | 130 | } |
| @@ -213,8 +213,8 @@ void DataRow::SetDecimalValue(int32_t index, const Nullable<decimal_t>& value) · 82 unmodified lines | |||
| 213 | // The boost decimal type has a very complex internal representation, | 213 | // The boost decimal type has a very complex internal representation, |
| 214 | // although slower, it's safer just to store this as a string for now | 214 | // although slower, it's safer just to store this as a string for now |
| 215 | const string& strval = value.GetValueOrDefault().str(); | 215 | const string& strval = value.GetValueOrDefault().str(); |
| 216 | const int32_t length = strval.size(); | 216 | const int32_t length = strval.size() + 1; |
| 217 | char* copy = static_cast<char*>(malloc(length + 1)); | 217 | char* copy = static_cast<char*>(malloc(length * sizeof(char))); |
| 218 | strcpy_s(copy, length, strval.c_str()); | 218 | strcpy_s(copy, length, strval.c_str()); |
| 219 | m_values[index] = copy; | 219 | m_values[index] = copy; |
| 220 | } | 220 | } |