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

Coverity report data leak #304

Closed
danielwangksu opened this issue Jul 22, 2019 · 2 comments
Closed

Coverity report data leak #304

danielwangksu opened this issue Jul 22, 2019 · 2 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@danielwangksu
Copy link

It seems request.buffer_ = new eprosima::fastcdr::FastBuffer(); did not get deleted

onNewDataMessage(eprosima::fastrtps::Subscriber * sub)
{
assert(sub);
CustomServiceRequest request;
request.buffer_ = new eprosima::fastcdr::FastBuffer();
eprosima::fastrtps::SampleInfo_t sinfo;
rmw_fastrtps_shared_cpp::SerializedData data;
data.is_cdr_buffer = true;
data.data = request.buffer_;
if (sub->takeNextData(&data, &sinfo)) {
if (eprosima::fastrtps::rtps::ALIVE == sinfo.sampleKind) {
request.sample_identity_ = sinfo.sample_identity;
std::lock_guard<std::mutex> lock(internalMutex_);
if (conditionMutex_ != nullptr) {
std::unique_lock<std::mutex> clock(*conditionMutex_);
list.push_back(request);
// the change to list_has_data_ needs to be mutually exclusive with
// rmw_wait() which checks hasData() and decides if wait() needs to
// be called
list_has_data_.store(true);
clock.unlock();
conditionVariable_->notify_one();
} else {
list.push_back(request);
list_has_data_.store(true);
}
}
}
}

@mabelzhang mabelzhang added bug Something isn't working help wanted Extra attention is needed labels Aug 22, 2019
@mabelzhang
Copy link

@danielwangksu Thanks for finding these! Do you want to open a PR to address this and #305?

@clalancette
Copy link
Contributor

This one has long been refactored and changed to fix the leak, so I'll close this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants