Both issues reported in QTBUG-120396 came from the same dubious piece of
code, which predates the public Qt history
if (path->size() >= 2 && in[0].unicode() == '.' && in[1].unicode() == '/')
in += 2;
else if (path->size() >= 3 && in[0].unicode() == '.'
&& in[1].unicode() == '.' && in[2].unicode() == '/')
in += 3;
It makes no sense to check path->size() inside the loop, as the in
pointer will have advanced past the beginning and the remaining size of
the input will not be path->size().
It additionally had theoretical UB in expressions like
in <= end - 4
for paths that were less than 4 characters long (it cannot happen with
current QString because of the QArrayData header before the payload).
So this commit rewrites the function to fix those issues and some others
found during the unit-testing. It gives the function a major
simplification.
Fixes: QTBUG-120396
Pick-to: 6.7 6.5
Change-Id: I46feca3a447244a8ba19fffd17e012c27e410056
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 4b1547adc9b195e6acc90471fc48dec7ee0c429d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
|
||
|---|---|---|
| .. | ||
| animation | ||
| global | ||
| io | ||
| ipc | ||
| itemmodels | ||
| kernel | ||
| mimetypes | ||
| platform | ||
| plugin | ||
| serialization | ||
| text | ||
| thread | ||
| time | ||
| tools | ||
| CMakeLists.txt | ||