Skip to content

[lldb] Check max_size before resizing DataBufferHeap #3947

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

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lldb/include/lldb/Utility/DataBufferHeap.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class DataBufferHeap : public DataBuffer {
/// to resize itself to.
///
/// \return
/// The size in bytes after that this heap buffer was
/// successfully resized to.
/// The size in bytes after this heap buffer was resized. If
/// the resize failed the size will remain unchanged.
lldb::offset_t SetByteSize(lldb::offset_t byte_size);

/// Makes a copy of the \a src_len bytes in \a src.
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Utility/DataBufferHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ uint64_t DataBufferHeap::GetByteSize() const { return m_data.size(); }
// Sets the number of bytes that this object should be able to contain. This
// can be used prior to copying data into the buffer.
uint64_t DataBufferHeap::SetByteSize(uint64_t new_size) {
m_data.resize(new_size);
if (new_size < m_data.max_size())
m_data.resize(new_size);
return m_data.size();
}

Expand Down