Bug 103342, 113590: ns{C}String::SubstituteString hangs/crashes. r=dbaron, sr=alecf

git-svn-id: svn://10.0.0.236/trunk@111271 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jaggernaut%netscape.com
2002-01-02 23:54:25 +00:00
parent b1bf161f3d
commit 6f56f8ad09
4 changed files with 12 additions and 4 deletions

View File

@@ -413,14 +413,16 @@ nsCString::ReplaceSubstring(const nsCString& aTarget,const nsCString& aNewValue)
//Since target is longer than newValue, we should delete a few chars first, then overwrite.
PRInt32 theDelLen=aTarget.mLength-aNewValue.mLength;
nsStr::Delete(*this,theIndex,theDelLen);
nsStr::Overwrite(*this,aNewValue,theIndex);
}
else {
//this is the worst case: the newvalue is larger than the substr it's replacing
//so we have to insert some characters...
PRInt32 theInsLen=aNewValue.mLength-aTarget.mLength;
StrInsert(*this,theIndex,aNewValue,0,theInsLen);
nsStr::Overwrite(*this,aNewValue,theIndex);
theIndex += aNewValue.mLength;
}
nsStr::Overwrite(*this,aNewValue,theIndex);
}
}
}