From a58f31dd27654400eb75242912a2067f64bc6984 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Sun, 25 Jul 2010 20:13:02 +0200 Subject: [PATCH] ddraw: Tighten up checks in DuplicateSurface (Coverity). --- dlls/ddraw/ddraw.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c index e55ac5bbde8..502cc847f36 100644 --- a/dlls/ddraw/ddraw.c +++ b/dlls/ddraw/ddraw.c @@ -4052,11 +4052,11 @@ static HRESULT WINAPI ddraw3_DuplicateSurface(IDirectDraw3 *iface, HRESULT hr; TRACE("iface %p, src %p, dst %p.\n", iface, src, dst); - - src7 = src ? (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)src) : NULL; + src7 = (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)src); hr = ddraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw3(iface), src7, &dst7); - *dst = dst7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)dst7)->IDirectDrawSurface3_vtbl : NULL; - + if (!SUCCEEDED(hr)) + return hr; + *dst = (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)dst7)->IDirectDrawSurface3_vtbl; return hr; } @@ -4067,11 +4067,11 @@ static HRESULT WINAPI ddraw2_DuplicateSurface(IDirectDraw2 *iface, HRESULT hr; TRACE("iface %p, src %p, dst %p.\n", iface, src, dst); - - src7 = src ? (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)src) : NULL; + src7 = (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)src); hr = ddraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw2(iface), src7, &dst7); - *dst = dst7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)dst7)->IDirectDrawSurface3_vtbl : NULL; - + if (!SUCCEEDED(hr)) + return hr; + *dst = (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)dst7)->IDirectDrawSurface3_vtbl; return hr; } @@ -4082,11 +4082,11 @@ static HRESULT WINAPI ddraw1_DuplicateSurface(IDirectDraw *iface, HRESULT hr; TRACE("iface %p, src %p, dst %p.\n", iface, src, dst); - - src7 = src ? (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)src) : NULL; + src7 = (IDirectDrawSurface7 *)surface_from_surface3((IDirectDrawSurface3 *)src); hr = ddraw7_DuplicateSurface((IDirectDraw7 *)ddraw_from_ddraw1(iface), src7, &dst7); - *dst = dst7 ? (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)dst7)->IDirectDrawSurface3_vtbl : NULL; - + if (!SUCCEEDED(hr)) + return hr; + *dst = (IDirectDrawSurface *)&((IDirectDrawSurfaceImpl *)dst7)->IDirectDrawSurface3_vtbl; return hr; }