]> git.saurik.com Git - wxWidgets.git/commitdiff
Ensure the buffer is NULL-terminated before converting it.
authorRobin Dunn <robin@alldunn.com>
Mon, 22 Mar 2004 18:35:35 +0000 (18:35 +0000)
committerRobin Dunn <robin@alldunn.com>
Mon, 22 Mar 2004 18:35:35 +0000 (18:35 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26297 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 d3e43c21a74287d861ac9fe015956be1b5b6b6e0..efedc9d76350fa24c6c61a6834d91f57748998dd 100644 (file)
@@ -2547,8 +2547,9 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
         if (len > 0)
         {
 #if wxUSE_UNICODE
-            wxMemoryBuffer buffer(len);
+            wxMemoryBuffer buffer(len+1);
             success = (file.Read(buffer.GetData(), len) == len);
+            ((char*)buffer.GetData())[len] = 0;
             contents = wxString(buffer, *wxConvCurrent);
 #else
             wxString buffer;
index 7459ffa401ed44758d28da62f1087e280ba8effd..473e08d38ef3552af69848f652e2cc4fbc918b7c 100644 (file)
@@ -356,8 +356,9 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
         if (len > 0)
         {
 #if wxUSE_UNICODE
-            wxMemoryBuffer buffer(len);
+            wxMemoryBuffer buffer(len+1);
             success = (file.Read(buffer.GetData(), len) == len);
+            ((char*)buffer.GetData())[len] = 0;
             contents = wxString(buffer, *wxConvCurrent);
 #else
             wxString buffer;
index d3e43c21a74287d861ac9fe015956be1b5b6b6e0..efedc9d76350fa24c6c61a6834d91f57748998dd 100644 (file)
@@ -2547,8 +2547,9 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
         if (len > 0)
         {
 #if wxUSE_UNICODE
-            wxMemoryBuffer buffer(len);
+            wxMemoryBuffer buffer(len+1);
             success = (file.Read(buffer.GetData(), len) == len);
+            ((char*)buffer.GetData())[len] = 0;
             contents = wxString(buffer, *wxConvCurrent);
 #else
             wxString buffer;
index 7459ffa401ed44758d28da62f1087e280ba8effd..473e08d38ef3552af69848f652e2cc4fbc918b7c 100644 (file)
@@ -356,8 +356,9 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename)
         if (len > 0)
         {
 #if wxUSE_UNICODE
-            wxMemoryBuffer buffer(len);
+            wxMemoryBuffer buffer(len+1);
             success = (file.Read(buffer.GetData(), len) == len);
+            ((char*)buffer.GetData())[len] = 0;
             contents = wxString(buffer, *wxConvCurrent);
 #else
             wxString buffer;