c42f / tinyformat

Minimal, type safe printf replacement library for C++
537 stars 75 forks source link

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

Closed dakep closed 4 years ago

dakep commented 4 years ago

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.

dakep commented 4 years ago

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