summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qiodevice.cpp4
-rw-r--r--src/corelib/io/qiodevice_p.h10
2 files changed, 9 insertions, 5 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index a60aee1ebe..07634c3ca2 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -789,8 +789,10 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
readSoFar += lastReadChunkSize;
// fast exit when satisfied by buffer
if (lastReadChunkSize == maxSize && !(d->openMode & Text)) {
- if (d->buffer.isEmpty())
+ if (d->buffer.isEmpty()) {
+ d->buffer.clear();
readData(data, 0);
+ }
return readSoFar;
}
diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h
index 4819ec11a0..362ea4bdf0 100644
--- a/src/corelib/io/qiodevice_p.h
+++ b/src/corelib/io/qiodevice_p.h
@@ -78,8 +78,11 @@ public:
delete [] buf;
}
void clear() {
- first = buf;
len = 0;
+ delete [] buf;
+ buf = 0;
+ first = buf;
+ capacity = 0;
}
int size() const {
return len;
@@ -129,10 +132,9 @@ public:
}
}
QByteArray readAll() {
- char* f = first;
- int l = len;
+ QByteArray retVal(first, len);
clear();
- return QByteArray(f, l);
+ return retVal;
}
int readLine(char* target, int size) {
int r = qMin(size, len);