summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-05-06 09:35:42 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-05-07 00:51:11 +0200
commit61c83dfb220f2e0d452a5e87a5a9b6fa45a9e6a9 (patch)
treea31432ba4ecfd6cd1e9c8479163c32aed08194d3
parent6245d7dd3b669dd4032c487de6522e7e51d0f39e (diff)
QXmlStreamReader: port Value::pos from int to qsizetype
It's an index into a QString, so it has to be qsizetype. The length and prefix fields also shouldn't stay ints, but that's a different patch, because they're just relative offsets to pos, and so aren't as easily overflown. This enlarges the Value struct; created QTBUG-103306 to track ideas to shrink it again. Pick-to: 6.3 6.2 Task-number: QTBUG-102465 Change-Id: Ib318e131420c2c535e26cb03cbf450e031626e64 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/corelib/serialization/qxmlstream.g8
-rw-r--r--src/corelib/serialization/qxmlstream_p.h2
-rw-r--r--src/corelib/serialization/qxmlstreamparser_p.h8
3 files changed, 9 insertions, 9 deletions
diff --git a/src/corelib/serialization/qxmlstream.g b/src/corelib/serialization/qxmlstream.g
index 713c5a17e0..ca798b46ac 100644
--- a/src/corelib/serialization/qxmlstream.g
+++ b/src/corelib/serialization/qxmlstream.g
@@ -873,7 +873,7 @@ processing_instruction ::= LANGLE QUESTIONMARK name space;
/.
case $rule_number: {
setType(QXmlStreamReader::ProcessingInstruction);
- int pos = sym(4).pos + sym(4).len;
+ const qsizetype pos = sym(4).pos + sym(4).len;
processingInstructionTarget = symString(3);
if (scanUntil("?>")) {
processingInstructionData = XmlStringRef(&textBuffer, pos, textBuffer.size() - pos - 2);
@@ -925,7 +925,7 @@ comment ::= comment_start RANGLE;
/.
case $rule_number: {
setType(QXmlStreamReader::Comment);
- int pos = sym(1).pos + 4;
+ const qsizetype pos = sym(1).pos + 4;
text = XmlStringRef(&textBuffer, pos, textBuffer.size() - pos - 3);
} break;
./
@@ -937,7 +937,7 @@ cdata ::= langle_bang CDATA_START;
setType(QXmlStreamReader::Characters);
isCDATA = true;
isWhitespace = false;
- int pos = sym(2).pos;
+ const qsizetype pos = sym(2).pos;
if (scanUntil("]]>", -1)) {
text = XmlStringRef(&textBuffer, pos, textBuffer.size() - pos - 3);
} else {
@@ -1216,7 +1216,7 @@ attribute ::= qname space_opt EQ space_opt attribute_value;
}
if (normalize) {
// normalize attribute value (simplify and trim)
- int pos = textBuffer.size();
+ const qsizetype pos = textBuffer.size();
int n = 0;
bool wasSpace = true;
for (int i = 0; i < attribute.value.len; ++i) {
diff --git a/src/corelib/serialization/qxmlstream_p.h b/src/corelib/serialization/qxmlstream_p.h
index b797fe830e..60558ab189 100644
--- a/src/corelib/serialization/qxmlstream_p.h
+++ b/src/corelib/serialization/qxmlstream_p.h
@@ -409,7 +409,7 @@ public:
int tos;
int stack_size;
struct Value {
- int pos;
+ qsizetype pos; // offset into textBuffer
int len;
int prefix;
ushort c;
diff --git a/src/corelib/serialization/qxmlstreamparser_p.h b/src/corelib/serialization/qxmlstreamparser_p.h
index 0a3e60e233..a0ac276fd8 100644
--- a/src/corelib/serialization/qxmlstreamparser_p.h
+++ b/src/corelib/serialization/qxmlstreamparser_p.h
@@ -574,7 +574,7 @@ bool QXmlStreamReaderPrivate::parse()
case 96: {
setType(QXmlStreamReader::ProcessingInstruction);
- int pos = sym(4).pos + sym(4).len;
+ const qsizetype pos = sym(4).pos + sym(4).len;
processingInstructionTarget = symString(3);
if (scanUntil("?>")) {
processingInstructionData = XmlStringRef(&textBuffer, pos, textBuffer.size() - pos - 2);
@@ -613,7 +613,7 @@ bool QXmlStreamReaderPrivate::parse()
case 100: {
setType(QXmlStreamReader::Comment);
- int pos = sym(1).pos + 4;
+ const qsizetype pos = sym(1).pos + 4;
text = XmlStringRef(&textBuffer, pos, textBuffer.size() - pos - 3);
} break;
@@ -621,7 +621,7 @@ bool QXmlStreamReaderPrivate::parse()
setType(QXmlStreamReader::Characters);
isCDATA = true;
isWhitespace = false;
- int pos = sym(2).pos;
+ const qsizetype pos = sym(2).pos;
if (scanUntil("]]>", -1)) {
text = XmlStringRef(&textBuffer, pos, textBuffer.size() - pos - 3);
} else {
@@ -779,7 +779,7 @@ bool QXmlStreamReaderPrivate::parse()
}
if (normalize) {
// normalize attribute value (simplify and trim)
- int pos = textBuffer.size();
+ const qsizetype pos = textBuffer.size();
int n = 0;
bool wasSpace = true;
for (int i = 0; i < attribute.value.len; ++i) {