Commit c7b04983 authored by beidson's avatar beidson

Reviewed by Maciej

        Plugged a leak in StringImpl::replace()

        * platform/StringImpl.cpp:
        (WebCore::StringImpl::replace):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@16065 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 91dde07e
2006-08-27 Brady Eidson <beidson@apple.com>
Reviewed by Maciej
Plugged a leak in StringImpl::replace()
* platform/StringImpl.cpp:
(WebCore::StringImpl::replace):
2006-08-27 Nikolas Zimmermann <zimmermann@kde.org>
Reviewed and landed by Anders.
......
......@@ -762,12 +762,16 @@ StringImpl* StringImpl::replace(UChar pattern, const StringImpl* str)
{
int slen = str ? str->length() : 0;
int index = 0;
StringImpl* result = this;
while ((index = result->find(pattern, index)) >= 0) {
result = result->replace(index, 1, str);
StringImpl* oldResult = this;
StringImpl* newResult;
while ((index = oldResult->find(pattern, index)) >= 0) {
newResult = oldResult->replace(index, 1, str);
if (oldResult != this)
delete oldResult;
oldResult = newResult;
index += slen;
}
return result;
return oldResult;
}
bool equal(const StringImpl* a, const StringImpl* b)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment