]> git.saurik.com Git - wxWidgets.git/commitdiff
Check that the file successfully loaded, use the length read for the conversion.
authorRobin Dunn <robin@alldunn.com>
Mon, 29 Mar 2004 20:01:16 +0000 (20:01 +0000)
committerRobin Dunn <robin@alldunn.com>
Mon, 29 Mar 2004 20:01:16 +0000 (20:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

contrib/src/stc/stc.cpp
contrib/src/stc/stc.cpp.in
src/stc/stc.cpp
src/stc/stc.cpp.in

index efedc9d76350fa24c6c61a6834d91f57748998dd..c3a5c5a725bfd36fb744765e1410e358f2decb16 100644 (file)
@@ -2549,8 +2549,10 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
 #if wxUSE_UNICODE
             wxMemoryBuffer buffer(len+1);
             success = (file.Read(buffer.GetData(), len) == len);
-            ((char*)buffer.GetData())[len] = 0;
-            contents = wxString(buffer, *wxConvCurrent);
+           if (success) {
+                ((char*)buffer.GetData())[len] = 0;
+                contents = wxString(buffer, *wxConvCurrent, len);
+            }
 #else
             wxString buffer;
             success = (file.Read(wxStringBuffer(buffer, len), len) == len);
index 473e08d38ef3552af69848f652e2cc4fbc918b7c..a859ec1a47e8a2a97f2987770cc25193c92e7a73 100644 (file)
@@ -358,8 +358,10 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
 #if wxUSE_UNICODE
             wxMemoryBuffer buffer(len+1);
             success = (file.Read(buffer.GetData(), len) == len);
-            ((char*)buffer.GetData())[len] = 0;
-            contents = wxString(buffer, *wxConvCurrent);
+           if (success) {
+                ((char*)buffer.GetData())[len] = 0;
+                contents = wxString(buffer, *wxConvCurrent, len);
+            }
 #else
             wxString buffer;
             success = (file.Read(wxStringBuffer(buffer, len), len) == len);
index efedc9d76350fa24c6c61a6834d91f57748998dd..c3a5c5a725bfd36fb744765e1410e358f2decb16 100644 (file)
@@ -2549,8 +2549,10 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
 #if wxUSE_UNICODE
             wxMemoryBuffer buffer(len+1);
             success = (file.Read(buffer.GetData(), len) == len);
-            ((char*)buffer.GetData())[len] = 0;
-            contents = wxString(buffer, *wxConvCurrent);
+           if (success) {
+                ((char*)buffer.GetData())[len] = 0;
+                contents = wxString(buffer, *wxConvCurrent, len);
+            }
 #else
             wxString buffer;
             success = (file.Read(wxStringBuffer(buffer, len), len) == len);
index 473e08d38ef3552af69848f652e2cc4fbc918b7c..a859ec1a47e8a2a97f2987770cc25193c92e7a73 100644 (file)
@@ -358,8 +358,10 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
 #if wxUSE_UNICODE
             wxMemoryBuffer buffer(len+1);
             success = (file.Read(buffer.GetData(), len) == len);
-            ((char*)buffer.GetData())[len] = 0;
-            contents = wxString(buffer, *wxConvCurrent);
+           if (success) {
+                ((char*)buffer.GetData())[len] = 0;
+                contents = wxString(buffer, *wxConvCurrent, len);
+            }
 #else
             wxString buffer;
             success = (file.Read(wxStringBuffer(buffer, len), len) == len);