Author: greatlrd
Date: Sun Jun 17 02:05:16 2007
New Revision: 27210
URL:
http://svn.reactos.org/svn/reactos?rev=27210&view=rev
Log:
fixing one more bugs in QueryInterface
Modified:
trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c
Modified: trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/Ddraw/dd…
==============================================================================
--- trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c (original)
+++ trunk/reactos/dll/directx/ddraw/Ddraw/ddraw_main.c Sun Jun 17 02:05:16 2007
@@ -39,78 +39,110 @@
*/
if (IsEqualGUID(&IID_IDirectDraw7, id))
{
- LPDDRAWI_DIRECTDRAW_INT newThis;
- DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
-
- if (newThis == NULL)
- {
- retVal = DDERR_OUTOFMEMORY;
+ if (This->lpVtbl != &DirectDraw7_Vtable)
+ {
+ LPDDRAWI_DIRECTDRAW_INT newThis;
+ DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
+
+ if (newThis == NULL)
+ {
+ retVal = DDERR_OUTOFMEMORY;
+ }
+ else
+ {
+ /* DirectDraw7 Vtable */
+ newThis->lpVtbl = &DirectDraw7_Vtable;
+ newThis->lpLcl = This->lpLcl;
+ newThis->lpLink = This;
+ *obj = &newThis->lpVtbl;
+ Main_DirectDraw_AddRef((LPDIRECTDRAW7)newThis);
+ }
}
else
{
- /* DirectDraw7 Vtable */
- newThis->lpVtbl = &DirectDraw7_Vtable;
- newThis->lpLcl = This->lpLcl;
- newThis->lpLink = This;
- *obj = &newThis->lpVtbl;
- Main_DirectDraw_AddRef((LPDIRECTDRAW7)newThis);
+ *obj = This;
+ Main_DirectDraw_AddRef((LPDIRECTDRAW7)This);
}
}
else if (IsEqualGUID(&IID_IDirectDraw4, id))
{
- LPDDRAWI_DIRECTDRAW_INT newThis;
- DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
-
- if (newThis == NULL)
- {
- retVal = DDERR_OUTOFMEMORY;
+ if (This->lpVtbl != &DirectDraw4_Vtable)
+ {
+ LPDDRAWI_DIRECTDRAW_INT newThis;
+ DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
+
+ if (newThis == NULL)
+ {
+ retVal = DDERR_OUTOFMEMORY;
+ }
+ else
+ {
+ /* DirectDraw4 Vtable */
+ newThis->lpVtbl = &DirectDraw4_Vtable;
+ newThis->lpLcl = This->lpLcl;
+ newThis->lpLink = This;
+ *obj = &newThis->lpVtbl;
+ Main_DirectDraw_AddRef((LPDIRECTDRAW7)newThis);
+ }
}
else
{
- /* DirectDraw4 Vtable */
- newThis->lpVtbl = &DirectDraw4_Vtable;
- newThis->lpLcl = This->lpLcl;
- newThis->lpLink = This;
- *obj = &newThis->lpVtbl;
- Main_DirectDraw_AddRef((LPDIRECTDRAW7)newThis);
+ *obj = This;
+ Main_DirectDraw_AddRef((LPDIRECTDRAW7)This);
}
}
else if (IsEqualGUID(&IID_IDirectDraw2, id))
{
- LPDDRAWI_DIRECTDRAW_INT newThis;
- DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
-
- if (newThis == NULL)
- {
- retVal = DDERR_OUTOFMEMORY;
+ if (This->lpVtbl != &DirectDraw2_Vtable)
+ {
+ LPDDRAWI_DIRECTDRAW_INT newThis;
+ DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
+
+ if (newThis == NULL)
+ {
+ retVal = DDERR_OUTOFMEMORY;
+ }
+ else
+ {
+ /* DirectDraw4 Vtable */
+ newThis->lpVtbl = &DirectDraw2_Vtable;
+ newThis->lpLcl = This->lpLcl;
+ newThis->lpLink = This;
+ *obj = &newThis->lpVtbl;
+ Main_DirectDraw_AddRef((LPDIRECTDRAW7)newThis);
+ }
}
else
{
- /* DirectDraw4 Vtable */
- newThis->lpVtbl = &DirectDraw2_Vtable;
- newThis->lpLcl = This->lpLcl;
- newThis->lpLink = This;
- *obj = &newThis->lpVtbl;
- Main_DirectDraw_AddRef((LPDIRECTDRAW7)newThis);
+ *obj = This;
+ Main_DirectDraw_AddRef((LPDIRECTDRAW7)This);
}
}
else if (IsEqualGUID(&IID_IDirectDraw, id))
{
- LPDDRAWI_DIRECTDRAW_INT newThis;
- DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
-
- if (newThis == NULL)
- {
- retVal = DDERR_OUTOFMEMORY;
+ if (This->lpVtbl != &DirectDraw_Vtable)
+ {
+ LPDDRAWI_DIRECTDRAW_INT newThis;
+ DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
+
+ if (newThis == NULL)
+ {
+ retVal = DDERR_OUTOFMEMORY;
+ }
+ else
+ {
+ /* DirectDraw4 Vtable */
+ newThis->lpVtbl = &DirectDraw_Vtable;
+ newThis->lpLcl = This->lpLcl;
+ newThis->lpLink = This;
+ *obj = &newThis->lpVtbl;
+ Main_DirectDraw_AddRef((LPDIRECTDRAW7)newThis);
+ }
}
else
{
- /* DirectDraw4 Vtable */
- newThis->lpVtbl = &DirectDraw_Vtable;
- newThis->lpLcl = This->lpLcl;
- newThis->lpLink = This;
- *obj = &newThis->lpVtbl;
- Main_DirectDraw_AddRef((LPDIRECTDRAW7)newThis);
+ *obj = This;
+ Main_DirectDraw_AddRef((LPDIRECTDRAW7)This);
}
}
else