From 183bd439fa18053dc6f96e224d33817090dcffd9 Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Wed, 5 Feb 2014 00:20:22 +0100 Subject: [PATCH] qedit: Don't dereference NULL on alloc failure. --- 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 d2523a84bfc..d4c9dddcf31 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; ipins[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; } -- 2.11.4.GIT