Fix crash when appending items of empty vector to wxItemContainer
Passing an empty std::vector<wxString> to Append() or Insert() methods of any wxItemContainer-derived classes, such as e.g. wxComboBox, resulted in undefined behaviour due to accessing the first element of an empty vector. Fix this by avoiding using it when the vector is empty.
This commit is contained in:
@@ -494,7 +494,7 @@ public:
|
||||
wxArrayStringsAdapter(const std::vector<wxString>& strings)
|
||||
: m_type(wxSTRING_POINTER), m_size(strings.size())
|
||||
{
|
||||
m_data.ptr = &strings[0];
|
||||
m_data.ptr = m_size == 0 ? NULL : &strings[0];
|
||||
}
|
||||
#endif // wxUSE_STD_CONTAINERS_COMPATIBLY
|
||||
|
||||
|
Reference in New Issue
Block a user