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

Always return a real slice even when the length is 0 #4368

Closed
wants to merge 1 commit into from

Conversation

normanmaurer
Copy link
Member

Motivation:

We need to always return a real slice even when the requested length is 0. This is needed as otherwise we not correctly share the reference count and so may leak a buffer if the user call release() on the returned slice and expect it to decrement the reference count of the "parent" buffer.

Modifications:

  • Always return a real slice
  • Add unit test for the bug.

Result:

No more leak possible when a user requests a slice of length 0 of a SlicedByteBuf.

Motivation:

We need to always return a real slice even when the requested length is 0. This is needed as otherwise we not correctly share the reference count and so may leak a buffer if the user call release() on the returned slice and expect it to decrement the reference count of the "parent" buffer.

Modifications:

- Always return a real slice
- Add unit test for the bug.

Result:

No more leak possible when a user requests a slice of length 0 of a SlicedByteBuf.
@normanmaurer normanmaurer self-assigned this Oct 16, 2015
@normanmaurer normanmaurer added this to the 4.0.33.Final milestone Oct 16, 2015
@Scottmitch
Copy link
Member

lgtm

@nmittler
Copy link
Member

LGTM

@normanmaurer
Copy link
Member Author

Cherry-picked into 4.0 (31ef237) , 4.1 (8f13e33) and master (2eaf8f7)

@normanmaurer normanmaurer deleted the fix_slice_slice_leak branch October 16, 2015 18:46
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.

None yet

4 participants