From 3e3fdbe831f24365780383b3c45a3d53f23ba435 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Tue, 11 Aug 2020 14:22:58 +0200 Subject: [PATCH] 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 Pick-to: 5.12 5.15 Change-Id: I581bd109f9b973e1c70b7b41b1f610a2ad5725b8 Reviewed-by: Thiago Macieira --- src/corelib/serialization/qxmlstream.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index 1296908110..ba6e3059df 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 (decoder.isValid()) nbytesread = 0; if (device) {