crypt32: NULL ptr could leak into function (Coverity).
[wine] / dlls / mshtml / htmlembed.c
1 /*
2  * Copyright 2010 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include <stdarg.h>
20
21 #define COBJMACROS
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "winreg.h"
27 #include "ole2.h"
28
29 #include "wine/debug.h"
30
31 #include "mshtml_private.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34
35 typedef struct {
36     HTMLElement element;
37
38     const IHTMLEmbedElementVtbl *lpIHTMLEmbedElementVtbl;
39 } HTMLEmbedElement;
40
41 #define HTMLEMBED(x)  (&(x)->lpIHTMLEmbedElementVtbl)
42
43 #define HTMLEMBED_THIS(iface) DEFINE_THIS(HTMLEmbedElement, IHTMLEmbedElement, iface)
44
45 static HRESULT WINAPI HTMLEmbedElement_QueryInterface(IHTMLEmbedElement *iface,
46         REFIID riid, void **ppv)
47 {
48     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
49
50     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
51 }
52
53 static ULONG WINAPI HTMLEmbedElement_AddRef(IHTMLEmbedElement *iface)
54 {
55     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
56
57     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
58 }
59
60 static ULONG WINAPI HTMLEmbedElement_Release(IHTMLEmbedElement *iface)
61 {
62     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
63
64     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
65 }
66
67 static HRESULT WINAPI HTMLEmbedElement_GetTypeInfoCount(IHTMLEmbedElement *iface, UINT *pctinfo)
68 {
69     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
70     return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
71 }
72
73 static HRESULT WINAPI HTMLEmbedElement_GetTypeInfo(IHTMLEmbedElement *iface, UINT iTInfo,
74         LCID lcid, ITypeInfo **ppTInfo)
75 {
76     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
77     return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
78             ppTInfo);
79 }
80
81 static HRESULT WINAPI HTMLEmbedElement_GetIDsOfNames(IHTMLEmbedElement *iface, REFIID riid,
82         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
83 {
84     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
85     return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
86             cNames, lcid, rgDispId);
87 }
88
89 static HRESULT WINAPI HTMLEmbedElement_Invoke(IHTMLEmbedElement *iface, DISPID dispIdMember,
90         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
91         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
92 {
93     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
94     return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
95             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
96 }
97
98 static HRESULT WINAPI HTMLEmbedElement_put_hidden(IHTMLEmbedElement *iface, BSTR v)
99 {
100     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
101     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
102     return E_NOTIMPL;
103 }
104
105 static HRESULT WINAPI HTMLEmbedElement_get_hidden(IHTMLEmbedElement *iface, BSTR *p)
106 {
107     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
108     FIXME("(%p)->(%p)\n", This, p);
109     return E_NOTIMPL;
110 }
111
112 static HRESULT WINAPI HTMLEmbedElement_get_palete(IHTMLEmbedElement *iface, BSTR *p)
113 {
114     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
115     FIXME("(%p)->(%p)\n", This, p);
116     return E_NOTIMPL;
117 }
118
119 static HRESULT WINAPI HTMLEmbedElement_get_pluginspage(IHTMLEmbedElement *iface, BSTR *p)
120 {
121     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
122     FIXME("(%p)->(%p)\n", This, p);
123     return E_NOTIMPL;
124 }
125
126 static HRESULT WINAPI HTMLEmbedElement_put_src(IHTMLEmbedElement *iface, BSTR v)
127 {
128     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
129     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
130     return E_NOTIMPL;
131 }
132
133 static HRESULT WINAPI HTMLEmbedElement_get_src(IHTMLEmbedElement *iface, BSTR *p)
134 {
135     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
136     FIXME("(%p)->(%p)\n", This, p);
137     return E_NOTIMPL;
138 }
139
140 static HRESULT WINAPI HTMLEmbedElement_put_units(IHTMLEmbedElement *iface, BSTR v)
141 {
142     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
143     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
144     return E_NOTIMPL;
145 }
146
147 static HRESULT WINAPI HTMLEmbedElement_get_units(IHTMLEmbedElement *iface, BSTR *p)
148 {
149     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
150     FIXME("(%p)->(%p)\n", This, p);
151     return E_NOTIMPL;
152 }
153
154 static HRESULT WINAPI HTMLEmbedElement_put_name(IHTMLEmbedElement *iface, BSTR v)
155 {
156     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
157     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
158     return E_NOTIMPL;
159 }
160
161 static HRESULT WINAPI HTMLEmbedElement_get_name(IHTMLEmbedElement *iface, BSTR *p)
162 {
163     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
164     FIXME("(%p)->(%p)\n", This, p);
165     return E_NOTIMPL;
166 }
167
168 static HRESULT WINAPI HTMLEmbedElement_put_width(IHTMLEmbedElement *iface, VARIANT v)
169 {
170     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
171     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
172     return E_NOTIMPL;
173 }
174
175 static HRESULT WINAPI HTMLEmbedElement_get_width(IHTMLEmbedElement *iface, VARIANT *p)
176 {
177     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
178     FIXME("(%p)->(%p)\n", This, p);
179     return E_NOTIMPL;
180 }
181
182 static HRESULT WINAPI HTMLEmbedElement_put_height(IHTMLEmbedElement *iface, VARIANT v)
183 {
184     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
185     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
186     return E_NOTIMPL;
187 }
188
189 static HRESULT WINAPI HTMLEmbedElement_get_height(IHTMLEmbedElement *iface, VARIANT *p)
190 {
191     HTMLEmbedElement *This = HTMLEMBED_THIS(iface);
192     FIXME("(%p)->(%p)\n", This, p);
193     return E_NOTIMPL;
194 }
195
196 #undef HTMLEMBED_THIS
197
198 static const IHTMLEmbedElementVtbl HTMLEmbedElementVtbl = {
199     HTMLEmbedElement_QueryInterface,
200     HTMLEmbedElement_AddRef,
201     HTMLEmbedElement_Release,
202     HTMLEmbedElement_GetTypeInfoCount,
203     HTMLEmbedElement_GetTypeInfo,
204     HTMLEmbedElement_GetIDsOfNames,
205     HTMLEmbedElement_Invoke,
206     HTMLEmbedElement_put_hidden,
207     HTMLEmbedElement_get_hidden,
208     HTMLEmbedElement_get_palete,
209     HTMLEmbedElement_get_pluginspage,
210     HTMLEmbedElement_put_src,
211     HTMLEmbedElement_get_src,
212     HTMLEmbedElement_put_units,
213     HTMLEmbedElement_get_units,
214     HTMLEmbedElement_put_name,
215     HTMLEmbedElement_get_name,
216     HTMLEmbedElement_put_width,
217     HTMLEmbedElement_get_width,
218     HTMLEmbedElement_put_height,
219     HTMLEmbedElement_get_height
220 };
221
222 static inline HTMLEmbedElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
223 {
224     return CONTAINING_RECORD(iface, HTMLEmbedElement, element.node);
225 }
226
227 static HRESULT HTMLEmbedElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
228 {
229     HTMLEmbedElement *This = impl_from_HTMLDOMNode(iface);
230
231     if(IsEqualGUID(&IID_IUnknown, riid)) {
232         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
233         *ppv = HTMLEMBED(This);
234     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
235         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
236         *ppv = HTMLEMBED(This);
237     }else if(IsEqualGUID(&IID_IHTMLEmbedElement, riid)) {
238         TRACE("(%p)->(IID_IHTMLEmbedElement %p)\n", This, ppv);
239         *ppv = HTMLEMBED(This);
240     }else {
241         return HTMLElement_QI(&This->element.node, riid, ppv);
242     }
243
244     IUnknown_AddRef((IUnknown*)*ppv);
245     return S_OK;
246 }
247
248 static void HTMLEmbedElement_destructor(HTMLDOMNode *iface)
249 {
250     HTMLEmbedElement *This = impl_from_HTMLDOMNode(iface);
251
252     HTMLElement_destructor(&This->element.node);
253 }
254
255 static const NodeImplVtbl HTMLEmbedElementImplVtbl = {
256     HTMLEmbedElement_QI,
257     HTMLEmbedElement_destructor,
258     HTMLElement_clone
259 };
260
261 static const tid_t HTMLEmbedElement_iface_tids[] = {
262     HTMLELEMENT_TIDS,
263     IHTMLEmbedElement_tid,
264     0
265 };
266 static dispex_static_data_t HTMLEmbedElement_dispex = {
267     NULL,
268     DispHTMLEmbed_tid,
269     NULL,
270     HTMLEmbedElement_iface_tids
271 };
272
273 HRESULT HTMLEmbedElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
274 {
275     HTMLEmbedElement *ret;
276
277     ret = heap_alloc_zero(sizeof(*ret));
278     if(!ret)
279         return E_OUTOFMEMORY;
280
281     ret->lpIHTMLEmbedElementVtbl = &HTMLEmbedElementVtbl;
282     ret->element.node.vtbl = &HTMLEmbedElementImplVtbl;
283
284     HTMLElement_Init(&ret->element, doc, nselem, &HTMLEmbedElement_dispex);
285     *elem = &ret->element;
286     return S_OK;
287 }