oleaut32: Avoid calculating a pointer for an array member before validating array index.
Dmitry Timoshkov
dmitry at baikal.ru
Thu Sep 19 21:15:58 CDT 2013
---
dlls/oleaut32/typelib.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index 2877f1a..0ab3fc2 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -10629,7 +10629,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetFuncAndParamNames(ICreateTypeInfo2 *
UINT index, LPOLESTR *names, UINT numNames)
{
ITypeInfoImpl *This = info_impl_from_ICreateTypeInfo2(iface);
- TLBFuncDesc *func_desc = &This->funcdescs[index];
+ TLBFuncDesc *func_desc;
int i;
TRACE("%p %u %p %u\n", This, index, names, numNames);
@@ -10640,6 +10640,8 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetFuncAndParamNames(ICreateTypeInfo2 *
if (index >= This->cFuncs || numNames == 0)
return TYPE_E_ELEMENTNOTFOUND;
+ func_desc = &This->funcdescs[index];
+
if (func_desc->funcdesc.invkind & (INVOKE_PROPERTYPUT | INVOKE_PROPERTYPUTREF)){
if(numNames > func_desc->funcdesc.cParams)
return TYPE_E_ELEMENTNOTFOUND;
@@ -10722,7 +10724,6 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetFuncDocString(ICreateTypeInfo2 *ifac
UINT index, LPOLESTR docString)
{
ITypeInfoImpl *This = info_impl_from_ICreateTypeInfo2(iface);
- TLBFuncDesc *func_desc = &This->funcdescs[index];
TRACE("%p %u %s\n", This, index, wine_dbgstr_w(docString));
@@ -10732,7 +10733,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetFuncDocString(ICreateTypeInfo2 *ifac
if(index >= This->cFuncs)
return TYPE_E_ELEMENTNOTFOUND;
- func_desc->HelpString = TLB_append_str(&This->pTypeLib->string_list, docString);
+ This->funcdescs[index].HelpString = TLB_append_str(&This->pTypeLib->string_list, docString);
return S_OK;
}
@@ -10741,7 +10742,6 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetVarDocString(ICreateTypeInfo2 *iface
UINT index, LPOLESTR docString)
{
ITypeInfoImpl *This = info_impl_from_ICreateTypeInfo2(iface);
- TLBVarDesc *var_desc = &This->vardescs[index];
TRACE("%p %u %s\n", This, index, wine_dbgstr_w(docString));
@@ -10751,7 +10751,7 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetVarDocString(ICreateTypeInfo2 *iface
if(index >= This->cVars)
return TYPE_E_ELEMENTNOTFOUND;
- var_desc->HelpString = TLB_append_str(&This->pTypeLib->string_list, docString);
+ This->vardescs[index].HelpString = TLB_append_str(&This->pTypeLib->string_list, docString);
return S_OK;
}
@@ -10760,14 +10760,13 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetFuncHelpContext(ICreateTypeInfo2 *if
UINT index, DWORD helpContext)
{
ITypeInfoImpl *This = info_impl_from_ICreateTypeInfo2(iface);
- TLBFuncDesc *func_desc = &This->funcdescs[index];
TRACE("%p %u %d\n", This, index, helpContext);
if(index >= This->cFuncs)
return TYPE_E_ELEMENTNOTFOUND;
- func_desc->helpcontext = helpContext;
+ This->funcdescs[index].helpcontext = helpContext;
return S_OK;
}
@@ -10776,14 +10775,13 @@ static HRESULT WINAPI ICreateTypeInfo2_fnSetVarHelpContext(ICreateTypeInfo2 *ifa
UINT index, DWORD helpContext)
{
ITypeInfoImpl *This = info_impl_from_ICreateTypeInfo2(iface);
- TLBVarDesc *var_desc = &This->vardescs[index];
TRACE("%p %u %d\n", This, index, helpContext);
if(index >= This->cVars)
return TYPE_E_ELEMENTNOTFOUND;
- var_desc->HelpContext = helpContext;
+ This->vardescs[index].HelpContext = helpContext;
return S_OK;
}
--
1.8.3.4
More information about the wine-patches
mailing list