Commit d5876529 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Do not use QStringView of a temporary

QString::mid() return a temporary QString. QStringView doesn't actually
hold any reference to data, so the temporary gets deleted somewhere
after we create the string view, which makes the string view invalid. So
instead, use QStringRef here for which there is a separate method.
parent 74f02648
......@@ -152,13 +152,13 @@ QString CGroupPrivate::unescapeName(const QString &name) {
if (escapeCharIndex < 0) {
break;
}
const QStringView sequence = rc.mid(escapeCharIndex, 4);
const QStringRef sequence = rc.midRef(escapeCharIndex, 4);
if (sequence.length() != 4 || sequence.at(1) != QLatin1Char('x')) {
qWarning() << "Badly formed cgroup name" << name;
return name;
}
bool ok;
int character = sequence.mid(2).toString().toInt(&ok, 16);
int character = sequence.mid(2).toInt(&ok, 16);
if (ok) {
rc.replace(escapeCharIndex, 4, QLatin1Char(character));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment