Bug 1889496 - Fix the potential incomplete type when accessing nsPluginElement with RefPtr. r=layout-reviewers,emilio

We may get build bustages for fuzzer/asan build without this change:
`member access into incomplete type 'nsPluginElement'`.

nsMimeTypeArray.h forward-declares the `nsPluginElement` type, so it's not
supposed to have any code that calls methods on instances of that type.
The `do_AddRef` inline function internally calls `AddRef` on the passed-in
thing, so we need to move that to the .cpp file which has the actual type
definition available.

Differential Revision: https://phabricator.services.mozilla.com/D206724
This commit is contained in:
Boris Chiou 2024-04-05 21:03:06 +00:00
parent 7fc0ce825d
commit a1ca30417e
2 changed files with 5 additions and 3 deletions

View File

@ -94,3 +94,7 @@ JSObject* nsMimeType::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return MimeType_Binding::Wrap(aCx, this, aGivenProto);
}
already_AddRefed<nsPluginElement> nsMimeType::EnabledPlugin() const {
return do_AddRef(mPluginElement);
}

View File

@ -83,9 +83,7 @@ class nsMimeType final : public nsWrapperCache {
retval.SetKnownLiveString(kMimeDescription);
}
already_AddRefed<nsPluginElement> EnabledPlugin() const {
return do_AddRef(mPluginElement);
}
already_AddRefed<nsPluginElement> EnabledPlugin() const;
void GetSuffixes(mozilla::dom::DOMString& retval) const {
retval.SetKnownLiveString(kMimeSuffix);