[PATCH 1/2] qedit: Don't dereference NULL on alloc failure.

Michael Stefaniuc mstefani at redhat.de
Tue Feb 4 17:20:22 CST 2014


The callers of pinsenum_create() already deal with a NULL return.
---
 dlls/qedit/samplegrabber.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/dlls/qedit/samplegrabber.c b/dlls/qedit/samplegrabber.c
index d2523a8..d4c9ddd 100644
--- a/dlls/qedit/samplegrabber.c
+++ b/dlls/qedit/samplegrabber.c
@@ -173,20 +173,24 @@ static const IEnumPinsVtbl IEnumPins_VTable =
 
 static IEnumPins *pinsenum_create(IBaseFilter *filter, IPin **pins, ULONG pinCount)
 {
+    PE_Impl *obj;
     ULONG len = sizeof(PE_Impl) + (pinCount * sizeof(IPin *));
-    PE_Impl *obj = CoTaskMemAlloc(len);
-    if (obj) {
-        ULONG i;
-        ZeroMemory(obj, len);
-        obj->pe.lpVtbl = &IEnumPins_VTable;
-        obj->refCount = 1;
-        obj->filter = filter;
-        obj->numPins = pinCount;
-        obj->index = 0;
-        for (i=0; i<pinCount; i++)
-            obj->pins[i] = pins[i];
-        IBaseFilter_AddRef(filter);
-    }
+    ULONG i;
+
+    obj = CoTaskMemAlloc(len);
+    if (!obj)
+        return NULL;
+
+    ZeroMemory(obj, len);
+    obj->pe.lpVtbl = &IEnumPins_VTable;
+    obj->refCount = 1;
+    obj->filter = filter;
+    obj->numPins = pinCount;
+    obj->index = 0;
+    for (i = 0; i < pinCount; i++)
+        obj->pins[i] = pins[i];
+    IBaseFilter_AddRef(filter);
+
     return &obj->pe;
 }
 
-- 
1.8.3.1



More information about the wine-patches mailing list