зеркало из https://github.com/mozilla/gecko-dev.git
Bug 103342, 113590: ns{C}String::SubstituteString hangs/crashes. r=dbaron, sr=alecf
This commit is contained in:
Родитель
3bf0f38457
Коммит
3910746e27
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -430,14 +430,16 @@ nsString::ReplaceSubstring(const nsString& aTarget,const nsString& 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -430,14 +430,16 @@ nsString::ReplaceSubstring(const nsString& aTarget,const nsString& 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче