Skip to content

Commit

Permalink
[GLUTEN-8476][VL] Fix allocate and free memory (#8477)
Browse files Browse the repository at this point in the history
fix security volations
  • Loading branch information
jkhaliqi authored Jan 10, 2025
1 parent cd327f9 commit 4bdda17
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cpp/core/benchmarks/CompressionBenchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ void printTrace(void) {
for (i = 0; i < size; i++)
printf(" %s\n", strings[i]);
puts("");
free(strings);
if (strings != nullptr) {
free(strings);
}
}

using arrow::RecordBatchReader;
Expand Down
2 changes: 2 additions & 0 deletions cpp/core/memory/MemoryAllocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ bool StdMemoryAllocator::reallocate(void* p, int64_t size, int64_t newSize, void
}

bool StdMemoryAllocator::reallocateAligned(void* p, uint64_t alignment, int64_t size, int64_t newSize, void** out) {
GLUTEN_CHECK(p != nullptr, "reallocate with nullptr");
if (newSize <= 0) {
return false;
}
Expand All @@ -179,6 +180,7 @@ bool StdMemoryAllocator::reallocateAligned(void* p, uint64_t alignment, int64_t
}

bool StdMemoryAllocator::free(void* p, int64_t size) {
GLUTEN_CHECK(p != nullptr, "free with nullptr");
std::free(p);
bytes_ -= size;
return true;
Expand Down

0 comments on commit 4bdda17

Please sign in to comment.