Module: wine Branch: master Commit: 90090332a25f69674b5ee1808cba09ff0123062f URL: http://source.winehq.org/git/wine.git/?a=commit;h=90090332a25f69674b5ee1808c...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Fri Jan 14 23:30:17 2011 +0300
oleaut32/safearray: Fix allocation error check for array descriptor.
---
dlls/oleaut32/safearray.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/oleaut32/safearray.c b/dlls/oleaut32/safearray.c index f8f87eb..dd00cfd 100644 --- a/dlls/oleaut32/safearray.c +++ b/dlls/oleaut32/safearray.c @@ -172,11 +172,15 @@ static ULONG SAFEARRAY_GetCellCount(const SAFEARRAY *psa) /* Allocate a descriptor for an array */ static HRESULT SAFEARRAY_AllocDescriptor(ULONG ulSize, SAFEARRAY **ppsaOut) { - *ppsaOut = (SAFEARRAY*)((char*)SAFEARRAY_Malloc(ulSize + SAFEARRAY_HIDDEN_SIZE) + SAFEARRAY_HIDDEN_SIZE); + char *ptr = SAFEARRAY_Malloc(ulSize + SAFEARRAY_HIDDEN_SIZE);
- if (!*ppsaOut) - return E_UNEXPECTED; + if (!ptr) + { + *ppsaOut = NULL; + return E_UNEXPECTED; + }
+ *ppsaOut = (SAFEARRAY*)(ptr + SAFEARRAY_HIDDEN_SIZE); return S_OK; }