[PATCH] coverity: handle NULL ptr case

Marcus Meissner marcus at jet.franken.de
Fri Nov 2 03:49:10 CDT 2007


Hi,

If pstgmed is NULL, the rest of the tests can be skipped,
because they dereference pstgmed and would just crash.

Spotted by Coverity.

Ciao, Marcus
---
 dlls/urlmon/tests/url.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/dlls/urlmon/tests/url.c b/dlls/urlmon/tests/url.c
index cd8432d..32bb31e 100644
--- a/dlls/urlmon/tests/url.c
+++ b/dlls/urlmon/tests/url.c
@@ -1096,11 +1096,13 @@ static HRESULT WINAPI statusclb_OnDataAvailable(IBindStatusCallback *iface, DWOR
     }
 
     ok(pstgmed != NULL, "stgmeg == NULL\n");
-    if(pstgmed) {
-        ok(pstgmed->tymed == TYMED_ISTREAM, "tymed=%u\n", pstgmed->tymed);
-        ok(U(*pstgmed).pstm != NULL, "pstm == NULL\n");
-        ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
+    if(!pstgmed) {
+	skip("further pstgmed related tests here.\n");
+	return S_OK;
     }
+    ok(pstgmed->tymed == TYMED_ISTREAM, "tymed=%u\n", pstgmed->tymed);
+    ok(U(*pstgmed).pstm != NULL, "pstm == NULL\n");
+    ok(pstgmed->pUnkForRelease != NULL, "pUnkForRelease == NULL\n");
 
     if(grfBSCF & BSCF_FIRSTDATANOTIFICATION) {
         hres = IStream_Write(U(*pstgmed).pstm, buf, 10, NULL);
-- 
1.5.2.4



More information about the wine-patches mailing list