aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4stringobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-09-12 13:11:11 +0200
committerLars Knoll <lars.knoll@qt.io>2020-09-15 13:32:47 +0200
commite3023dba6d716eebf89b76dcaa5a2451df30ed18 (patch)
tree0e2762ea570cd6ec68ffc9be5026b656970636ce /src/qml/jsruntime/qv4stringobject.cpp
parent98a31ff6b9673b020a688d7d035f03a6497a6f5f (diff)
Do not write the 0 terminator for QString
QString does this for us in any case, and writing there was always undefined behavior. This is causing problems after an optimization in QString, where creating a QString with size 0 will avoid any memory allocation and simply point to the (readonly) _empty member in QString. Change-Id: I0516dc2e8672b8290efa891bd9b5486dac8021b6 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4stringobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 97a8941fe1..e9e47c1b52 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -208,7 +208,6 @@ ReturnedValue StringCtor::method_fromCharCode(const FunctionObject *b, const Val
*ch = QChar(argv[i].toUInt16());
++ch;
}
- *ch = 0;
return Encode(b->engine()->newString(str));
}
@@ -235,7 +234,6 @@ ReturnedValue StringCtor::method_fromCodePoint(const FunctionObject *f, const Va
}
++ch;
}
- *ch = 0;
result.truncate(ch - result.constData());
return e->newString(result)->asReturnedValue();
}