check for empty data pointer in Len() and Empty()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@766 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder 1998-09-21 20:13:41 +00:00
parent 1c4a764c98
commit ecadfc3f5a

View File

@ -254,13 +254,13 @@ public:
/** @name generic attributes & operations */
//@{
/// as standard strlen()
size_t Len() const { return GetStringData()->nDataLength; }
size_t Len() const { return GetStringData() ? GetStringData()->nDataLength : 0; }
/// string contains any characters?
bool IsEmpty() const { return Len() == 0; }
/// reinitialize string (and free data!)
void Empty()
{
if ( GetStringData()->nDataLength != 0 )
if ( GetStringData() && GetStringData()->nDataLength != 0 )
Reinit();
wxASSERT( GetStringData()->nDataLength == 0 );