]> git.saurik.com Git - wxWidgets.git/commitdiff
check for empty data pointer in Len() and Empty()
authorKarsten Ballüder <ballueder@usa.net>
Mon, 21 Sep 1998 20:13:41 +0000 (20:13 +0000)
committerKarsten Ballüder <ballueder@usa.net>
Mon, 21 Sep 1998 20:13:41 +0000 (20:13 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@766 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/string.h

index 44d6803a1b5d6edbf970dbc12744e282e95d71df..3b2512c3ddd81659b686411a8f15d6defb3b0186 100644 (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 );