Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GLUTEN-8476][VL] Fix allocate and free memory #8477

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jkhaliqi
Copy link

@jkhaliqi jkhaliqi commented Jan 8, 2025

What changes were proposed in this pull request?

Allocate and free memory in the same module

(Please fill in changes proposed in this fix)

(Fixes: #8476)

@github-actions github-actions bot added the VELOX label Jan 8, 2025
Copy link

github-actions bot commented Jan 8, 2025

#8476

@@ -172,14 +172,18 @@ bool StdMemoryAllocator::reallocateAligned(void* p, uint64_t alignment, int64_t
return false;
}
memcpy(reallocatedP, p, std::min(size, newSize));
std::free(p);
if (p != nullptr) {
Copy link
Contributor

@FelixYBW FelixYBW Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add the check of p at beginning 

if (newSize <= 0 && p==nullptr) {

*out = reallocatedP;
bytes_ += (newSize - size);
return true;
}

bool StdMemoryAllocator::free(void* p, int64_t size) {
std::free(p);
if (p != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to 
if (p==nullptr) return false;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[VL] Security Voliations Allocate and free memory in the same module
2 participants