From: Robin Dunn Date: Wed, 18 Aug 1999 06:27:58 +0000 (+0000) Subject: Fix to prevent Assert when there is an empty string in a combobox/choice. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/21d72d1755620c0017e872a5bc5a61fdea492c52 Fix to prevent Assert when there is an empty string in a combobox/choice. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3406 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index a40148b58b..3f104ea206 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -154,15 +154,15 @@ int wxChoice::FindString(const wxString& s) const wxString wxChoice::GetString(int n) const { size_t len = (size_t)::SendMessage(GetHwnd(), CB_GETLBTEXTLEN, n, 0); - wxString str; - if ( ::SendMessage(GetHwnd(), CB_GETLBTEXT, n, - (LPARAM)str.GetWriteBuf(len)) == CB_ERR ) - { - wxLogLastError("SendMessage(CB_GETLBTEXT)"); + wxString str = ""; + if (len) { + if ( ::SendMessage(GetHwnd(), CB_GETLBTEXT, n, + (LPARAM)str.GetWriteBuf(len)) == CB_ERR ) { + wxLogLastError("SendMessage(CB_GETLBTEXT)"); + } + str.UngetWriteBuf(); } - str.UngetWriteBuf(); - return str; }