From 6a3d01cd400ddf05b8864dcd01971f36254d4db7 Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Thu, 11 Mar 1999 21:31:03 +0000 Subject: [PATCH] Fix for 3630 -- terminate text and HTML strings returned from the editor. git-svn-id: svn://10.0.0.236/trunk@23766 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/editor/base/nsTextEditor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mozilla/editor/base/nsTextEditor.cpp b/mozilla/editor/base/nsTextEditor.cpp index 416d5e15962..93911b32e9c 100644 --- a/mozilla/editor/base/nsTextEditor.cpp +++ b/mozilla/editor/base/nsTextEditor.cpp @@ -545,10 +545,10 @@ NS_IMETHODIMP nsTextEditor::Insert(nsIInputStream *aInputStream) static void WriteFromStringstream(stringstream& aIn, nsString& aOutputString) { string theString = aIn.str(); - PRInt32 len = theString.length(); - aOutputString.SetLength(0); // empty the string + aOutputString.SetLength(0); // empty the string aOutputString += theString.data(); + aOutputString.SetLength(theString.length()); // make sure it's terminated /* relace LF with CR. Don't do this here, because strings passed out to JavaScript need LF termination. @@ -560,10 +560,11 @@ static void WriteFromStringstream(stringstream& aIn, nsString& aOutputString) #else static void WriteFromOstrstream(ostrstream& aIn, nsString& aOutputString) { - char* strData = aIn.str(); + char* strData = aIn.str(); // get a copy of the buffer (unterminated) aOutputString.SetLength(0); // empty the string aOutputString += strData; + aOutputString.SetLength(aIn.pcount()); // terminate // in ostrstreams if you call the str() function // then you are responsible for deleting the string