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:
parent
9d2f8ed652
commit
e6270075bd
@ -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);
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user