PluginArrayImpl::GetLength should not throw if there's no plugin host, and PluginArrayImpl::GetPlugins should handle no plugin host and failure from mPluginHost->GetPlugins

RESOLVED FIXED

Status

()

Core
Plug-ins
RESOLVED FIXED
13 years ago
13 years ago

People

(Reporter: timeless, Assigned: timeless)

Tracking

Trunk
x86
Windows XP
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Assignee)

Description

13 years ago
Error: uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIDOMPluginArray.length]"  nsresult: "0x80004005
(NS_ERROR_FAILURE)"  location: "JS frame :: javascript: navigator.plugins.length
:: <TOP_LEVEL> :: line 1"  data: no]
Error: uncaught exception: [Exception... "Failure"  nsresult: "0x80004005
(NS_ERROR_FAILURE)"  location: "JS frame :: javascript: navigator.plugins[0] ::
<TOP_LEVEL> :: line 1"  data: no]
Error: uncaught exception: [Exception... "Failure"  nsresult: "0x80004005
(NS_ERROR_FAILURE)"  location: "JS frame :: javascript: navigator.plugins.test
:: <TOP_LEVEL> :: line 1"  data: no]
(Assignee)

Comment 1

13 years ago
Created attachment 167783 [details] [diff] [review]
fix PluginArrayImpl. also clean up idl
(Assignee)

Updated

13 years ago
Attachment #167783 - Flags: superreview?(jst)
Comment on attachment 167783 [details] [diff] [review]
fix PluginArrayImpl. also clean up idl

sr=jst
Attachment #167783 - Flags: superreview?(jst) → superreview+
Comment on attachment 167783 [details] [diff] [review]
fix PluginArrayImpl. also clean up idl

>Index: dom/src/base/nsPluginArray.cpp
>     mPluginArray = new nsIDOMPlugin*[mPluginCount];
>+    if (!mPluginArray)
>+      return NS_ERROR_OUT_OF_MEMORY;
>+
>+    if (!mPluginCount)
>+      return NS_OK;

I'd prefer the mPluginCount check first, so we don't even allocate mPluginArray
when the plugin count is 0.  All accesses to mPluginArray check mPluginCount,
so it should be ok.

With that, r=bzbarsky.
Attachment #167783 - Flags: review+
(Assignee)

Comment 4

13 years ago
mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp 	1.513
mozilla/modules/plugin/base/src/nsPluginHostImpl.h 	1.96
mozilla/dom/src/base/nsPluginArray.cpp 	1.28
mozilla/modules/plugin/base/public/nsIPluginHost.idl 	1.3

i explained to bz why his suggestion doesn't work, and he was fine with it.
Status: NEW → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.