From: Karsten Ballüder Date: Mon, 21 Sep 1998 20:13:41 +0000 (+0000) Subject: check for empty data pointer in Len() and Empty() X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/ecadfc3f5a675d60fd5711c38a7b53f83079e5c5 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 --- diff --git a/include/wx/string.h b/include/wx/string.h index 44d6803a1b..3b2512c3dd 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -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 );