From db7b707d8105ae86bc9b197e7b7c399f23ece201 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 5 Apr 2024 16:20:29 +0200 Subject: [PATCH] Initialize QTextBoundaryFinder::pos to zero One constructor neglected to do so. Use NSDMI to make sure all constructors do, if they don't override this with something else. Also remove fatuous setting, by constructors, of member attributes to its default. Task-number: QTBUG-122619 Change-Id: I9b726898b85e21d841b9af5b4dc72ee322829d50 Reviewed-by: Thiago Macieira (cherry picked from commit 35205ef1654f2ee0aca80010acdbb469cf1cf8e7) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/text/qtextboundaryfinder.cpp | 4 ---- src/corelib/text/qtextboundaryfinder.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/corelib/text/qtextboundaryfinder.cpp b/src/corelib/text/qtextboundaryfinder.cpp index 8f20967a1d7..21d4c5153ea 100644 --- a/src/corelib/text/qtextboundaryfinder.cpp +++ b/src/corelib/text/qtextboundaryfinder.cpp @@ -173,9 +173,7 @@ QTextBoundaryFinder::QTextBoundaryFinder(BoundaryType type, const QString &strin : t(type) , s(string) , sv(s) - , pos(0) , freeBuffer(true) - , attributes(nullptr) { if (sv.size() > 0) { attributes = (QCharAttributes *) malloc((sv.size() + 1) * sizeof(QCharAttributes)); @@ -208,9 +206,7 @@ QTextBoundaryFinder::QTextBoundaryFinder(BoundaryType type, const QString &strin QTextBoundaryFinder::QTextBoundaryFinder(BoundaryType type, QStringView string, unsigned char *buffer, qsizetype bufferSize) : t(type) , sv(string) - , pos(0) , freeBuffer(true) - , attributes(nullptr) { if (!sv.isEmpty()) { if (buffer && bufferSize / int(sizeof(QCharAttributes)) >= sv.size() + 1) { diff --git a/src/corelib/text/qtextboundaryfinder.h b/src/corelib/text/qtextboundaryfinder.h index 336096d2d01..04e64fd69b3 100644 --- a/src/corelib/text/qtextboundaryfinder.h +++ b/src/corelib/text/qtextboundaryfinder.h @@ -63,7 +63,7 @@ private: BoundaryType t = Grapheme; QString s; QStringView sv; - qsizetype pos; + qsizetype pos = 0; uint freeBuffer : 1; uint unused : 31; QCharAttributes *attributes = nullptr;