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
This commit is contained in:
sfraser%netscape.com
1999-03-11 21:31:03 +00:00
parent 92d0f77a8c
commit 6a3d01cd40

View File

@@ -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