* with OwningNonNull isn't considered as safe to use arguments of MOZ_CAN_RUN_SCRIPT methods
Categories
(Developer Infrastructure :: Source Code Analysis, enhancement)
Tracking
(firefox68 fixed)
Tracking | Status | |
---|---|---|
firefox68 | --- | fixed |
People
(Reporter: masayuki, Assigned: bzbarsky)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
OwningNonNull<Element> element(*aElement);
foo->MozCanRunScript(*element);
is not considered as safe. However,
RefPtr<Element> element(aElement);
foo->MozCanRunScript(*element);
is considred as safe.
I think that *
for OwningNonNull
should be considered as safe like RefPtr
.
Comment 1•6 years ago
|
||
(I'm not quite sure about the component for static analysis bugs.)
![]() |
Assignee | |
Comment 2•6 years ago
•
|
||
(I'm not quite sure about the component for static analysis bugs.)
Generally speaking, "Firefox Build System : Source Code Analysis".
What's happening here is that RefPtr actually declares an operator* and we have code in the analysis to allow an overloaded operator* on smartptrs. OwningNonNull does not declare an operator*, so we end up with a UnaryOperator (that is, the default operator*) applied to a member call (the "T* operator()" that OwningNonNull defines).
We do have a check for UnaryOperator that's unaryDereferenceOperator(), but currently only allow function args and "this" with it.
I can change the analysis to allow something like ignoreTrivials(cxxMemberCallExpr(on(KnownLiveSmartPtr))) as the operand for the unary dereference, but I think it's a bit simpler to just declare an operator* on OwningNonNull.
Unfortunately, I can't add a test for this because including OwningNonNull in the analysis test file leads to:
0:01.22 error: 'warning' diagnostics seen but not expected:
0:01.22 Line 127: replacement function 'operator new' cannot be declared 'inline'
0:01.22 Line 134: replacement function 'operator new' cannot be declared 'inline'
0:01.22 Line 139: replacement function 'operator new[]' cannot be declared 'inline'
0:01.22 Line 144: replacement function 'operator new[]' cannot be declared 'inline'
0:01.22 Line 149: replacement function 'operator delete' cannot be declared 'inline'
0:01.22 Line 154: replacement function 'operator delete' cannot be declared 'inline'
0:01.22 Line 159: replacement function 'operator delete[]' cannot be declared 'inline'
0:01.22 Line 164: replacement function 'operator delete[]' cannot be declared 'inline'
![]() |
Assignee | |
Comment 3•6 years ago
|
||
Updated•6 years ago
|
Comment 5•6 years ago
|
||
bugherder |
Updated•6 years ago
|
Updated•3 years ago
|
Description
•