This is an automated email from the ASF dual-hosted git repository. haonan pushed a commit to branch iotdb in repository https://gitbox.apache.org/repos/asf/tsfile.git
commit f844be8f4521784b9200c9c77eb6fc898d7b1431 Author: Hongzhi Gao <[email protected]> AuthorDate: Thu Jun 27 11:25:57 2024 +0800 fix the class to prevent the program from crashing unexpectedly (#126) --- cpp/src/common/datatype/value.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cpp/src/common/datatype/value.h b/cpp/src/common/datatype/value.h index 5d91d776..c8284360 100644 --- a/cpp/src/common/datatype/value.h +++ b/cpp/src/common/datatype/value.h @@ -33,16 +33,16 @@ namespace common { struct Value { - Value(TSDataType type) : type_(type) {} + Value(TSDataType type) : type_(type), value_{0} {} ~Value() { - if (value_.sval_) { + if (is_type(NULL_TYPE) && value_.sval_) { free(value_.sval_); } } FORCE_INLINE void free_memory() { - if (value_.sval_) { + if (is_type(NULL_TYPE) && value_.sval_) { free(value_.sval_); value_.sval_ = nullptr; } @@ -80,7 +80,7 @@ struct Value { break; } case common::TEXT: { - value_.sval_ = strdup(val); + value_.sval_ = strdup((const char *)val); break; } default: { @@ -155,6 +155,7 @@ FORCE_INLINE std::string value_to_string(Value *value) { break; case common::NULL_TYPE: ss << "NULL"; + break; default: ASSERT(false); break;
