diff options
| author | Thiago Macieira <thiago.macieira@intel.com> | 2024-07-07 16:41:24 -0700 |
|---|---|---|
| committer | Thiago Macieira <thiago.macieira@intel.com> | 2024-08-03 01:24:46 -0700 |
| commit | 4b1547adc9b195e6acc90471fc48dec7ee0c429d (patch) | |
| tree | 3834265b5b6d5448bb340315046b760b8b8d9ee4 /src/widgets/doc/snippets/cmake-macros/examples.cpp | |
| parent | 297bc0fb306954dbdf34d80017055b6924315d81 (diff) | |
QUrl::resolved: rewrite to fix some corner cases for relative URLs
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.5 6.8
Change-Id: I46feca3a447244a8ba19fffd17e012c27e410056
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Diffstat (limited to 'src/widgets/doc/snippets/cmake-macros/examples.cpp')
0 files changed, 0 insertions, 0 deletions
