Module: wine Branch: master Commit: 83693d9611659eca62ae260ba6f6309e310594a5 URL: http://source.winehq.org/git/wine.git/?a=commit;h=83693d9611659eca62ae260ba6...
Author: Michael Stefaniuc mstefani@redhat.de Date: Fri Jan 27 14:42:22 2012 +0100
shell32: Avoid an unsafe IExtractIconW to object cast.
---
dlls/shell32/folders.c | 69 +++++++++++++++++++++++------------------------- 1 files changed, 33 insertions(+), 36 deletions(-)
diff --git a/dlls/shell32/folders.c b/dlls/shell32/folders.c index bab2b1c..b57fcf4 100644 --- a/dlls/shell32/folders.c +++ b/dlls/shell32/folders.c @@ -70,32 +70,7 @@ static inline IExtractIconWImpl *impl_from_IPersistFile(IPersistFile *iface) return CONTAINING_RECORD(iface, IExtractIconWImpl, IPersistFile_iface); }
-static const IExtractIconAVtbl eiavt; -static const IExtractIconWVtbl eivt; -static const IPersistFileVtbl pfvt;
- -/************************************************************************** -* IExtractIconW_Constructor -*/ -IExtractIconW* IExtractIconW_Constructor(LPCITEMIDLIST pidl) -{ - IExtractIconWImpl* ei; - - TRACE("%p\n", pidl); - - ei = HeapAlloc(GetProcessHeap(),0,sizeof(IExtractIconWImpl)); - ei->ref=1; - ei->IExtractIconW_iface.lpVtbl = &eivt; - ei->IExtractIconA_iface.lpVtbl = &eiavt; - ei->IPersistFile_iface.lpVtbl = &pfvt; - ei->pidl=ILClone(pidl); - - pdump(pidl); - - TRACE("(%p)\n", ei); - return &ei->IExtractIconW_iface; -} /************************************************************************** * IExtractIconW::QueryInterface */ @@ -404,17 +379,6 @@ static const IExtractIconWVtbl eivt = };
/************************************************************************** -* IExtractIconA_Constructor -*/ -IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl) -{ - IExtractIconWImpl *This = (IExtractIconWImpl *)IExtractIconW_Constructor(pidl); - IExtractIconA *eia = &This->IExtractIconA_iface; - - TRACE("(%p)->(%p)\n", This, eia); - return eia; -} -/************************************************************************** * IExtractIconA::QueryInterface */ static HRESULT WINAPI IExtractIconA_fnQueryInterface(IExtractIconA * iface, REFIID riid, @@ -564,3 +528,36 @@ static const IPersistFileVtbl pfvt = (void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */, (void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */ }; + +IExtractIconWImpl *extracticon_create(LPCITEMIDLIST pidl) +{ + IExtractIconWImpl *ei; + + TRACE("%p\n", pidl); + + ei = HeapAlloc(GetProcessHeap(), 0, sizeof(*ei)); + ei->ref=1; + ei->IExtractIconW_iface.lpVtbl = &eivt; + ei->IExtractIconA_iface.lpVtbl = &eiavt; + ei->IPersistFile_iface.lpVtbl = &pfvt; + ei->pidl=ILClone(pidl); + + pdump(pidl); + + TRACE("(%p)\n", ei); + return ei; +} + +IExtractIconW *IExtractIconW_Constructor(LPCITEMIDLIST pidl) +{ + IExtractIconWImpl *ei = extracticon_create(pidl); + + return &ei->IExtractIconW_iface; +} + +IExtractIconA *IExtractIconA_Constructor(LPCITEMIDLIST pidl) +{ + IExtractIconWImpl *ei = extracticon_create(pidl); + + return &ei->IExtractIconA_iface; +}