Null terminate the new buffer.

git-svn-id: svn://10.0.0.236/trunk@44979 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rpotts%netscape.com 1999-08-28 05:12:11 +00:00
parent 9d2f8ed652
commit e6270075bd
2 changed files with 8 additions and 2 deletions

View File

@ -346,7 +346,7 @@ nsGenericDOMDataNode::ReplaceData(PRUint32 aOffset, PRUint32 aCount,
}
PRInt32 dataLength = aData.Length();
PRInt32 newLength = textLength - aCount + dataLength;
PRUnichar* to = new PRUnichar[newLength ? newLength : 1];
PRUnichar* to = new PRUnichar[newLength ? newLength+1 : 1];
if (nsnull == to) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -366,6 +366,9 @@ nsGenericDOMDataNode::ReplaceData(PRUint32 aOffset, PRUint32 aCount,
mText.CopyTo(to + aOffset + dataLength, endOffset, textLength - endOffset);
}
// Null terminate the new buffer...
to[newLength] = (PRUnichar)0;
// Switch to new buffer
nsCOMPtr<nsITextContent> textContent = do_QueryInterface(mContent, &result);

View File

@ -346,7 +346,7 @@ nsGenericDOMDataNode::ReplaceData(PRUint32 aOffset, PRUint32 aCount,
}
PRInt32 dataLength = aData.Length();
PRInt32 newLength = textLength - aCount + dataLength;
PRUnichar* to = new PRUnichar[newLength ? newLength : 1];
PRUnichar* to = new PRUnichar[newLength ? newLength+1 : 1];
if (nsnull == to) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -366,6 +366,9 @@ nsGenericDOMDataNode::ReplaceData(PRUint32 aOffset, PRUint32 aCount,
mText.CopyTo(to + aOffset + dataLength, endOffset, textLength - endOffset);
}
// Null terminate the new buffer...
to[newLength] = (PRUnichar)0;
// Switch to new buffer
nsCOMPtr<nsITextContent> textContent = do_QueryInterface(mContent, &result);