diff options
author | Paul Wicking <paul.wicking@qt.io> | 2023-04-07 08:30:54 +0200 |
---|---|---|
committer | Paul Wicking <paul.wicking@qt.io> | 2023-04-07 17:29:44 +0200 |
commit | f8d73cf765c9c81d195ccd7e5f4f50574d82e859 (patch) | |
tree | 28cd69eb96bd6edea862da306c91a741c284be8b /src/designer/src/components/propertyeditor/propertyeditor.cpp | |
parent | 1c7cca268a06b5a3c34765e1e0e4dd1b020f3302 (diff) | |
download | qttools-f8d73cf765c9c81d195ccd7e5f4f50574d82e859.tar.gz |
QDoc: Prevent crash in WebXMLGenerator
`WebXMLGenerator::startLink` is responsible for writing the WebXML tags
for links. The method takes a pointer to `Atom`, from which a string is
obtained for use in parts of the output. In most locations, the callee
pre-qualifies the validity of the pointer it passes to the method
(e.g. `if (atom) startLink([...]`).
However, there's an exception to this in
`WebXMLGenerator::generateAnnotatedList`, which calls
`Text::firstAtom()` -- that may return `nullptr` -- in the call to
`startLink`. This is considered a valid use-case that occurs when
there's only title/meta commands and no body in the documentation.
In such a case, or if the string obtained from `Atom::string()` is
empty, `WebXMLGenerator::startLink` is designed to fall back to the
full name of the `Node` being processed. However, in the case when
generating a link for an example, `Generator::exampleFileTitle()` is
called to obtain a file name for the example, and the `Atom*` is
dereferenced to obtain a string is input for the latter method. At
that point, the `Atom*` may be an unguarded null pointer.
This change updates the generatedOutput test for QDoc by adding a
minimal documentation project that serves as means to reproduce a bug
that was observed in Qt3D, and fixes the bug in QDoc. The documentation
project is designed such that the preconditions outlined in the first
paragraph are met; that is to say, the structure of the documentation
is such that, for an `Atom` that's constructed while generating the
documentation set, `Atom::firstAtom()` is going to return a null
pointer. The change to the test serves to validate the bug fix as well
as to guard for future regressions.
Avoid the crash that would occur when dereferencing this null pointer
in `WebXMLGenerator::startLink` by checking the validity of the `Atom*`
before dereferencing it to obtain a string used as file title when
generating a link for an example.
Fixes: QTBUG-112641
Pick-to: 6.5
Change-Id: I3633e5473b60013968becac4cd7bdacdbbdcb9ff
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/designer/src/components/propertyeditor/propertyeditor.cpp')
0 files changed, 0 insertions, 0 deletions