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 | 123 | if (value.HasValue()) |
| 124 | 124 | { |
| 125 | 125 | const string& strval = value.GetValueOrDefault(); |
| 126 | − const int32_t length = strval.size(); | |
| 127 | − char* copy = static_cast<char*>(malloc(length + 1)); | |
| 126 | + const int32_t length = strval.size() + 1; | |
| 127 | + char* copy = static_cast<char*>(malloc(length * sizeof(char))); | |
| 128 | 128 | strcpy_s(copy, length, strval.c_str()); |
| 129 | 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 | 213 | // The boost decimal type has a very complex internal representation, |
| 214 | 214 | // although slower, it's safer just to store this as a string for now |
| 215 | 215 | const string& strval = value.GetValueOrDefault().str(); |
| 216 | − const int32_t length = strval.size(); | |
| 217 | − char* copy = static_cast<char*>(malloc(length + 1)); | |
| 216 | + const int32_t length = strval.size() + 1; | |
| 217 | + char* copy = static_cast<char*>(malloc(length * sizeof(char))); | |
| 218 | 218 | strcpy_s(copy, length, strval.c_str()); |
| 219 | 219 | m_values[index] = copy; |
| 220 | 220 | } |