diff options
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 3af53f5..74eabbf 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1591,12 +1591,12 @@ QString &QString::append(QChar ch) */ QString &QString::remove(int pos, int len) { - if (pos < 0) + if (pos < 0) // count from end of string pos += d->size; if (pos < 0 || pos >= d->size) { // range problems - } else if (pos + len >= d->size) { // pos ok - resize(pos); + } else if (len >= d->size - pos) { + resize(pos); // truncate } else if (len > 0) { detach(); memmove(d->data + pos, d->data + pos + len, |