Skip to content

Commit

Permalink
fix memory leak in Table::make_record (oceanbase#441)
Browse files Browse the repository at this point in the history
  • Loading branch information
nautaa authored Aug 26, 2024
1 parent ebe460e commit 39c442b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/observer/storage/table/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,21 +270,25 @@ RC Table::make_record(int value_num, const Value *values, Record &record)
char *record_data = (char *)malloc(record_size);
memset(record_data, 0, record_size);

for (int i = 0; i < value_num; i++) {
for (int i = 0; i < value_num && OB_SUCC(rc); i++) {
const FieldMeta *field = table_meta_.field(i + normal_field_start_index);
const Value & value = values[i];
if (field->type() != value.attr_type()) {
Value real_value;
rc = Value::cast_to(value, field->type(), real_value);
if (OB_FAIL(rc)) {
return rc;
LOG_WARN("failed to cast value. table name:%s,field name:%s,value:%s ",
table_meta_.name(), field->name(), value.to_string().c_str());
break;
}
rc = set_value_to_record(record_data, real_value, field);
} else {
rc = set_value_to_record(record_data, value, field);
}
}
if (OB_FAIL(rc)) {
LOG_WARN("failed to make record. table name:%s", table_meta_.name());
free(record_data);
return rc;
}

Expand Down

0 comments on commit 39c442b

Please sign in to comment.