From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/pluginhost.c | 25 ++++++++++++++++++------- dlls/mshtml/pluginhost.h | 8 +++++++- 2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/dlls/mshtml/pluginhost.c b/dlls/mshtml/pluginhost.c index 49e3c66a3e1..bbf93c2b713 100644 --- a/dlls/mshtml/pluginhost.c +++ b/dlls/mshtml/pluginhost.c @@ -712,9 +712,13 @@ static inline HTMLPluginContainer *impl_from_DispatchEx(DispatchEx *iface) void HTMLPluginContainer_destructor(DispatchEx *dispex) { HTMLPluginContainer *This = impl_from_DispatchEx(dispex); + unsigned int i;
if(This->plugin_host) detach_plugin_host(This->plugin_host); + + for(i = 0; i < This->props_len; i++) + free(This->props[i]); free(This->props);
HTMLElement_destructor(&This->element.node.event_target.dispex); @@ -723,9 +727,10 @@ void HTMLPluginContainer_destructor(DispatchEx *dispex) HRESULT HTMLPluginContainer_get_dispid(DispatchEx *dispex, const WCHAR *name, DWORD grfdex, DISPID *ret) { HTMLPluginContainer *plugin_container = impl_from_DispatchEx(dispex); + struct plugin_prop *prop; IDispatch *disp; DISPID id; - DWORD i; + DWORD i, len; HRESULT hres;
TRACE("(%p)->(%s %lx %p)\n", plugin_container, debugstr_w(name), grfdex, ret); @@ -746,21 +751,21 @@ HRESULT HTMLPluginContainer_get_dispid(DispatchEx *dispex, const WCHAR *name, DW }
for(i=0; i < plugin_container->props_len; i++) { - if(id == plugin_container->props[i]) { + if(id == plugin_container->props[i]->id) { *ret = MSHTML_DISPID_CUSTOM_MIN+i; return S_OK; } }
if(!plugin_container->props) { - plugin_container->props = malloc(8 * sizeof(DISPID)); + plugin_container->props = malloc(8 * sizeof(*plugin_container->props)); if(!plugin_container->props) return E_OUTOFMEMORY; plugin_container->props_size = 8; }else if(plugin_container->props_len == plugin_container->props_size) { - DISPID *new_props; + struct plugin_prop **new_props;
- new_props = realloc(plugin_container->props, plugin_container->props_size * 2 * sizeof(DISPID)); + new_props = realloc(plugin_container->props, plugin_container->props_size * 2 * sizeof(*new_props)); if(!new_props) return E_OUTOFMEMORY;
@@ -768,7 +773,13 @@ HRESULT HTMLPluginContainer_get_dispid(DispatchEx *dispex, const WCHAR *name, DW plugin_container->props_size *= 2; }
- plugin_container->props[plugin_container->props_len] = id; + len = wcslen(name); + if(!(prop = malloc(FIELD_OFFSET(struct plugin_prop, name[len + 1])))) + return E_OUTOFMEMORY; + + prop->id = id; + wcscpy(prop->name, name); + plugin_container->props[plugin_container->props_len] = prop; *ret = MSHTML_DISPID_CUSTOM_MIN+plugin_container->props_len; plugin_container->props_len++; return S_OK; @@ -798,7 +809,7 @@ HRESULT HTMLPluginContainer_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WOR return E_FAIL; }
- return IDispatch_Invoke(host->disp, plugin_container->props[id-MSHTML_DISPID_CUSTOM_MIN], &IID_NULL, + return IDispatch_Invoke(host->disp, plugin_container->props[id-MSHTML_DISPID_CUSTOM_MIN]->id, &IID_NULL, lcid, flags, params, res, ei, NULL); }
diff --git a/dlls/mshtml/pluginhost.h b/dlls/mshtml/pluginhost.h index f76aa5b10ca..afbbc40e657 100644 --- a/dlls/mshtml/pluginhost.h +++ b/dlls/mshtml/pluginhost.h @@ -48,12 +48,18 @@ typedef struct { HTMLPluginContainer *element; } PluginHost;
+struct plugin_prop +{ + DISPID id; + WCHAR name[1]; +}; + struct HTMLPluginContainer { HTMLElement element;
PluginHost *plugin_host;
- DISPID *props; + struct plugin_prop **props; DWORD props_size; DWORD props_len; };