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

Fix UB introduced by copying detail::FormatListN objects. #59

Merged
merged 2 commits into from
Nov 8, 2019
Merged

Fix UB introduced by copying detail::FormatListN objects. #59

merged 2 commits into from
Nov 8, 2019

Conversation

dakep
Copy link
Contributor

@dakep dakep commented Nov 7, 2019

When copying a detail::FormatListN object, the m_formatterStore must also be copied, otherwise the pointer in the parent FormatList class are possibly invalid.

This addresses the segfault explained in #58. The issue arises when makeFormatList returns an object which holds a pointer to memory created for the temporary object on the stack.

Copy link
Owner

@c42f c42f left a comment

Choose a reason for hiding this comment

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

Thanks for jumping in and fixing this, it's much appreciated (I still don't have an icc license, so pretty hard to test on my end).

I think those const_casts shouldn't be required. Other than that this looks great.

@dakep
Copy link
Contributor Author

dakep commented Nov 8, 2019

You are right! These const_casts are of course not required. 🤦‍♂

Copy link
Owner

@c42f c42f left a comment

Choose a reason for hiding this comment

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

Looks good now, let's merge this.

@c42f c42f merged commit 705e3f4 into c42f:master Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants