From 80f5aeeb85d5c2e030e4b3e8c55c13b87c9af482 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 26 Feb 2025 09:57:41 +0100 Subject: [PATCH] QByteArray: Make gcc 12 happy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It somehow concludes that asize may be negative and would then cast to an obscenely large size_t. This produces the following warning: .../qbytearray.cpp: In member function ‘replace.constprop.isra’: .../qbytearray.cpp:2579:23: warning: ‘memcpy’ specified bound between 9223372036854775808 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=] 2579 | memcpy(d + to, a, asize); | ^ Check for asize > 0 rather than asize != 0. Pick-to: 6.5 Change-Id: I63bccb1bf3ff45d539af4efe6843d2c648d7cb86 Reviewed-by: Marc Mutz (cherry picked from commit 177cd123d29f818413db4bb7a9d92b8485c95947) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit b9169c12105414e58b7a0244a867d6e8fa96f572) --- src/corelib/text/qbytearray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index dbef344f869..3253920dcb4 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -2551,7 +2551,7 @@ QByteArray &QByteArray::replace(QByteArrayView before, QByteArrayView after) } else { to = index; } - if (asize) { + if (asize > 0) { memcpy(d + to, a, asize); to += asize; }