Skip to content

Commit

Permalink
Merge pull request #2323 from ZhouBox/v2.10
Browse files Browse the repository at this point in the history
[v2.10]fix bug:data memory error
  • Loading branch information
fengzeroz authored Nov 28, 2024
2 parents a93950e + 5b1cb93 commit bb057f3
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/adapter/driver/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,125 +834,128 @@ static void fix_value(neu_datatag_t *tag, neu_type_e value_type,
break;
case NEU_TYPE_BYTES:
if (value->type == NEU_TYPE_ARRAY_INT64) {
value->value.bytes.length = value->value.i64s.length;
for (int i = 0; i < value->value.i64s.length; i++) {
value->value.bytes.bytes[i] =
(uint8_t) value->value.i64s.i64s[i];
}
for (int i = value->value.i64s.length; i < NEU_VALUE_SIZE; i++) {
value->value.bytes.bytes[i] = 0;
}
value->value.bytes.length = value->value.i64s.length;
}
break;
case NEU_TYPE_ARRAY_INT8:
if (value->type == NEU_TYPE_ARRAY_INT64) {
value->value.i8s.length = value->value.i64s.length;
for (int i = 0; i < value->value.i64s.length; i++) {
value->value.i8s.i8s[i] = (int8_t) value->value.i64s.i64s[i];
}
for (int i = value->value.i64s.length; i < NEU_VALUE_SIZE; i++) {
value->value.i8s.i8s[i] = 0;
}
value->value.i8s.length = value->value.i64s.length;
}
break;
case NEU_TYPE_ARRAY_UINT8:
if (value->type == NEU_TYPE_ARRAY_INT64) {
value->value.u8s.length = value->value.i64s.length;
for (int i = 0; i < value->value.i64s.length; i++) {
value->value.u8s.u8s[i] = (uint8_t) value->value.i64s.i64s[i];
}
for (int i = value->value.i64s.length; i < NEU_VALUE_SIZE; i++) {
value->value.u8s.u8s[i] = 0;
}
value->value.u8s.length = value->value.i64s.length;
}
break;
case NEU_TYPE_ARRAY_INT16:
if (value->type == NEU_TYPE_ARRAY_INT64) {
value->value.i16s.length = value->value.i64s.length;
for (int i = 0; i < value->value.i64s.length; i++) {
value->value.i16s.i16s[i] = (int16_t) value->value.i64s.i64s[i];
}
for (int i = value->value.i64s.length; i < NEU_VALUE_SIZE; i++) {
value->value.i16s.i16s[i] = 0;
}
value->value.i16s.length = value->value.i64s.length;
}
break;
case NEU_TYPE_ARRAY_UINT16:
if (value->type == NEU_TYPE_ARRAY_INT64) {
value->value.u16s.length = value->value.i64s.length;
for (int i = 0; i < value->value.i64s.length; i++) {
value->value.u16s.u16s[i] =
(uint16_t) value->value.i64s.i64s[i];
}
for (int i = value->value.i64s.length; i < NEU_VALUE_SIZE; i++) {
value->value.u16s.u16s[i] = 0;
}
value->value.u16s.length = value->value.i64s.length;
}
break;
case NEU_TYPE_ARRAY_INT32:
if (value->type == NEU_TYPE_ARRAY_INT64) {
value->value.i32s.length = value->value.i64s.length;
for (int i = 0; i < value->value.i64s.length; i++) {
value->value.i32s.i32s[i] = (int32_t) value->value.i64s.i64s[i];
}
for (int i = value->value.i64s.length; i < NEU_VALUE_SIZE; i++) {
value->value.i32s.i32s[i] = 0;
}
value->value.i32s.length = value->value.i64s.length;
}
break;
case NEU_TYPE_ARRAY_UINT32:
if (value->type == NEU_TYPE_ARRAY_INT64) {
value->value.u32s.length = value->value.i64s.length;
for (int i = 0; i < value->value.i64s.length; i++) {
value->value.u32s.u32s[i] =
(uint32_t) value->value.i64s.i64s[i];
}
for (int i = value->value.i64s.length; i < NEU_VALUE_SIZE; i++) {
value->value.u32s.u32s[i] = 0;
}
value->value.u32s.length = value->value.i64s.length;
}
break;
case NEU_TYPE_ARRAY_UINT64:
if (value->type == NEU_TYPE_ARRAY_INT64) {
value->value.u64s.length = value->value.i64s.length;
for (int i = 0; i < value->value.i64s.length; i++) {
value->value.u64s.u64s[i] =
(uint64_t) value->value.i64s.i64s[i];
}
for (int i = value->value.i64s.length; i < NEU_VALUE_SIZE; i++) {
value->value.u64s.u64s[i] = 0;
}
value->value.u64s.length = value->value.i64s.length;
}
break;
case NEU_TYPE_ARRAY_FLOAT:
if (value->type == NEU_TYPE_ARRAY_INT64) {
value->value.f32s.length = value->value.i64s.length;

for (int i = 0; i < value->value.i64s.length; i++) {
value->value.f32s.f32s[i] = (float) value->value.i64s.i64s[i];
}
for (int i = value->value.i64s.length; i < NEU_VALUE_SIZE; i++) {
value->value.f32s.f32s[i] = 0;
}
value->value.f32s.length = value->value.i64s.length;
}
if (value->type == NEU_TYPE_ARRAY_DOUBLE) {
value->value.f32s.length = value->value.f64s.length;

for (int i = 0; i < value->value.f64s.length; i++) {
value->value.f32s.f32s[i] = (float) value->value.f64s.f64s[i];
}
for (int i = value->value.f64s.length; i < NEU_VALUE_SIZE; i++) {
value->value.f32s.f32s[i] = 0;
}
value->value.f32s.length = value->value.f64s.length;
}
break;
case NEU_TYPE_ARRAY_DOUBLE:
if (value->type == NEU_TYPE_ARRAY_INT64) {
value->value.f64s.length = value->value.i64s.length;

for (int i = 0; i < value->value.i64s.length; i++) {
value->value.f64s.f64s[i] = (double) value->value.i64s.i64s[i];
}
for (int i = value->value.i64s.length; i < NEU_VALUE_SIZE; i++) {
value->value.f64s.f64s[i] = 0;
}
value->value.f64s.length = value->value.i64s.length;
}
break;
default:
Expand Down

0 comments on commit bb057f3

Please sign in to comment.