From 6f56f8ad09f8e4160dba4773e9469f33db625304 Mon Sep 17 00:00:00 2001 From: "jaggernaut%netscape.com" Date: Wed, 2 Jan 2002 23:54:25 +0000 Subject: [PATCH] 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 --- mozilla/string/obsolete/nsString.cpp | 4 +++- mozilla/string/obsolete/nsString2.cpp | 4 +++- mozilla/xpcom/string/obsolete/nsString.cpp | 4 +++- mozilla/xpcom/string/obsolete/nsString2.cpp | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/mozilla/string/obsolete/nsString.cpp b/mozilla/string/obsolete/nsString.cpp index f46d6532130..583825ff63c 100644 --- a/mozilla/string/obsolete/nsString.cpp +++ b/mozilla/string/obsolete/nsString.cpp @@ -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); } } } diff --git a/mozilla/string/obsolete/nsString2.cpp b/mozilla/string/obsolete/nsString2.cpp index e4801b91ac2..cf518ff89b6 100644 --- a/mozilla/string/obsolete/nsString2.cpp +++ b/mozilla/string/obsolete/nsString2.cpp @@ -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; } - nsStr::Overwrite(*this,aNewValue,theIndex); } } } diff --git a/mozilla/xpcom/string/obsolete/nsString.cpp b/mozilla/xpcom/string/obsolete/nsString.cpp index f46d6532130..583825ff63c 100644 --- a/mozilla/xpcom/string/obsolete/nsString.cpp +++ b/mozilla/xpcom/string/obsolete/nsString.cpp @@ -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); } } } diff --git a/mozilla/xpcom/string/obsolete/nsString2.cpp b/mozilla/xpcom/string/obsolete/nsString2.cpp index e4801b91ac2..cf518ff89b6 100644 --- a/mozilla/xpcom/string/obsolete/nsString2.cpp +++ b/mozilla/xpcom/string/obsolete/nsString2.cpp @@ -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; } - nsStr::Overwrite(*this,aNewValue,theIndex); } } }