Skip to content

Commit

Permalink
feat(tianmu): fix invalid write/read issue. (#817)
Browse files Browse the repository at this point in the history
  • Loading branch information
lujiashun committed Nov 8, 2022
1 parent eeca82b commit 6d89387
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion storage/tianmu/core/engine_results.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void scan_fields(mem_root_deque<Item *> &fields, uint *&buf_lens, std::map<int,
Item::Type item_type;
Item_sum::Sumfunctype sum_type;

buf_lens = new uint[CountVisibleFields(fields)]; // stonedb8
buf_lens = new uint[fields.size()];
uint item_id = 0;
uint field_length = 0;
uint total_length = 0;
Expand Down
7 changes: 1 addition & 6 deletions storage/tianmu/system/cacheable_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CacheableItem::CacheableItem(char const *owner_name, char const *object_id, int
// read the configuration parameter
std::string temp_filename = tianmu_sysvar_cachefolder;
filename_n_position = temp_filename.length();
filename = new char[filename_n_position + 37]; // "...path.../XXXXXXnnnnnnAAAAAAAABBBBBBBB.tianmu_tmp"
filename = new char[filename_n_position + 37 + 4]; // "...path.../XXXXXXnnnnnnAAAAAAAABBBBBBBB.tianmu_tmp"
std::strcpy(filename, temp_filename.c_str());
if (filename[filename_n_position - 1] != '/' && filename[filename_n_position - 1] != '\\') {
filename[filename_n_position] = '/';
Expand All @@ -43,11 +43,6 @@ CacheableItem::CacheableItem(char const *owner_name, char const *object_id, int
filename_n_position += 6;
}

if (filename == nullptr) {
// if the temporary path is not set, use the current folder
filename = new char[36]; // "XXXXXXnnnnnnAAAAAAAABBBBBBBB.tianmu_tmp"
filename_n_position = 6;
}
max_file_id = 0;
max_file_pos = 0;
no_block = 0;
Expand Down

0 comments on commit 6d89387

Please sign in to comment.