This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new b067bdc [Bug] fix overflow while convert fixed char to number (#6368)
b067bdc is described below
commit b067bdcdd54e22d70ef79e332816f182b3d5872a
Author: stdpain <[email protected]>
AuthorDate: Thu Aug 5 14:35:29 2021 +0800
[Bug] fix overflow while convert fixed char to number (#6368)
because Slice::size was unsigned int64, p >= 0 was always true
---
be/src/olap/types.h | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/be/src/olap/types.h b/be/src/olap/types.h
index a2fba4d..0dc5a9a 100644
--- a/be/src/olap/types.h
+++ b/be/src/olap/types.h
@@ -103,7 +103,9 @@ public:
inline void direct_copy(void* dest, const void* src) const override {
_direct_copy(dest, src); }
- inline void direct_copy_may_cut(void* dest, const void* src) const
override { _direct_copy_may_cut(dest, src); }
+ inline void direct_copy_may_cut(void* dest, const void* src) const
override {
+ _direct_copy_may_cut(dest, src);
+ }
//convert and deep copy value from other type's source
OLAPStatus convert_from(void* dest, const void* src, const TypeInfo*
src_type,
@@ -502,9 +504,7 @@ struct BaseFieldtypeTraits : public
CppTypeTraits<field_type> {
*reinterpret_cast<CppType*>(dest) = *reinterpret_cast<const
CppType*>(src);
}
- static inline void direct_copy_may_cut(void* dest, const void* src) {
- direct_copy(dest, src);
- }
+ static inline void direct_copy_may_cut(void* dest, const void* src) {
direct_copy(dest, src); }
static OLAPStatus convert_from(void* dest, const void* src, const
TypeInfo* src_type,
MemPool* mem_pool) {
@@ -540,7 +540,7 @@ struct BaseFieldtypeTraits : public
CppTypeTraits<field_type> {
static void prepare_char_before_convert(const void* src) {
Slice* slice = const_cast<Slice*>(reinterpret_cast<const Slice*>(src));
char* buf = slice->data;
- auto p = slice->size - 1;
+ int64_t p = slice->size - 1;
while (p >= 0 && buf[p] == '\0') {
p--;
}
@@ -717,9 +717,7 @@ struct FieldTypeTraits<OLAP_FIELD_TYPE_LARGEINT>
*reinterpret_cast<PackedInt128*>(dest) = *reinterpret_cast<const
PackedInt128*>(src);
}
- static inline void direct_copy_may_cut(void* dest, const void* src) {
- direct_copy(dest, src);
- }
+ static inline void direct_copy_may_cut(void* dest, const void* src) {
direct_copy(dest, src); }
static void set_to_max(void* buf) {
*reinterpret_cast<PackedInt128*>(buf) = ~((int128_t)(1) << 127);
@@ -1028,8 +1026,8 @@ struct FieldTypeTraits<OLAP_FIELD_TYPE_CHAR> : public
BaseFieldtypeTraits<OLAP_F
auto l_slice = reinterpret_cast<Slice*>(dest);
auto r_slice = reinterpret_cast<const Slice*>(src);
- auto min_size = MAX_ZONE_MAP_INDEX_SIZE >= r_slice->size ?
r_slice->size :
- MAX_ZONE_MAP_INDEX_SIZE;
+ auto min_size =
+ MAX_ZONE_MAP_INDEX_SIZE >= r_slice->size ? r_slice->size :
MAX_ZONE_MAP_INDEX_SIZE;
memory_copy(l_slice->data, r_slice->data, min_size);
l_slice->size = min_size;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]