This is an automated email from the ASF dual-hosted git repository.
jiangtian pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/tsfile.git
The following commit(s) were added to refs/heads/develop by this push:
new 4e457b64 fix the class to prevent the program from crashing
unexpectedly (#126)
4e457b64 is described below
commit 4e457b640536d5b6c288aa07de39c0bbcf737393
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;