diff options
author | Robert Loehning <robert.loehning@qt.io> | 2020-08-11 14:22:58 +0200 |
---|---|---|
committer | Robert Loehning <robert.loehning@qt.io> | 2020-09-22 16:08:57 +0000 |
commit | 92fe1eba0a1a87622b3306ef7050a28cfb291158 (patch) | |
tree | 3f06b9991fb0ef2fccdac12990b7b39546804f6f /src/corelib/serialization/qxmlstream.cpp | |
parent | 762414400535910d2a5b2e8024cae0c7fbec403f (diff) |
QXmlStreamReader: Don't resize readBuffer to a size it already has
Resizing it to 0 will cause it to allocate memory. This will then
cause append() to copy the data from the other string instead of
using copy on write.
Task-number: oss-fuzz-24347
Change-Id: I581bd109f9b973e1c70b7b41b1f610a2ad5725b8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 3e3fdbe831f24365780383b3c45a3d53f23ba435)
Diffstat (limited to 'src/corelib/serialization/qxmlstream.cpp')
-rw-r--r-- | src/corelib/serialization/qxmlstream.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index ddd331c12a..453a966c9a 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -1484,7 +1484,8 @@ uint QXmlStreamReaderPrivate::getChar_helper() const int BUFFER_SIZE = 8192; characterOffset += readBufferPos; readBufferPos = 0; - readBuffer.resize(0); + if (readBuffer.size()) + readBuffer.resize(0); #if QT_CONFIG(textcodec) if (decoder) #endif |