summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qbytearray.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <dangelog@gmail.com>2012-01-23 12:02:36 +0000
committerQt by Nokia <qt-info@nokia.com>2012-01-24 17:36:11 +0100
commit601d68584921a47d83d833228f5ec698e13b624c (patch)
tree235d066cefcb5a5f2a7d4029c9b5512fdb17b500 /src/corelib/tools/qbytearray.cpp
parentb39df8bf92a530783144dbcf5cae939742ff2d23 (diff)
Make mid() and midRef() properly return empty, non-null objects
If we request a substring starting at the very end of the string, QString::mid should return an empty string, not a null string. For instance, QString("abc").mid(3, 0) used to return a null one, while this patch makes it return an empty one. The same thing applies to QString::midRef() and QByteArray::mid(). Change-Id: Ie9efd7a0622d429efd0fb682c19856c19e9469af Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/tools/qbytearray.cpp')
-rw-r--r--src/corelib/tools/qbytearray.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 0ca2f47923..364f58f42c 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -2660,7 +2660,7 @@ QByteArray QByteArray::right(int len) const
QByteArray QByteArray::mid(int pos, int len) const
{
- if (d == &shared_null.ba || d == &shared_empty.ba || pos >= d->size)
+ if (d == &shared_null.ba || d == &shared_empty.ba || pos > d->size)
return QByteArray();
if (len < 0)
len = d->size - pos;