Jacek Caban : mshtml: Fixed dynamic properties allocation.
Alexandre Julliard
julliard at winehq.org
Mon Sep 22 07:03:58 CDT 2008
Module: wine
Branch: master
Commit: e9277986c85463f638328ffd7e64a48a21940427
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e9277986c85463f638328ffd7e64a48a21940427
Author: Jacek Caban <jacek at codeweavers.com>
Date: Sun Sep 21 17:26:01 2008 +0200
mshtml: Fixed dynamic properties allocation.
---
dlls/mshtml/dispex.c | 35 +++++++++++++++++++++++++++--------
1 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c
index 587d953..e176711 100644
--- a/dlls/mshtml/dispex.c
+++ b/dlls/mshtml/dispex.c
@@ -463,18 +463,37 @@ static HRESULT WINAPI DispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DW
}
if(grfdex & fdexNameEnsure) {
+ dispex_dynamic_data_t *dynamic_data;
+
TRACE("creating dynamic prop %s\n", debugstr_w(bstrName));
- if(!This->dynamic_data) {
- This->dynamic_data = heap_alloc_zero(sizeof(dispex_dynamic_data_t));
- This->dynamic_data->props = heap_alloc(This->dynamic_data->buf_size = 4);
- }else if(This->dynamic_data->buf_size == This->dynamic_data->prop_cnt) {
- This->dynamic_data->props = heap_realloc(This->dynamic_data->props, This->dynamic_data->buf_size<<=1);
+ if(This->dynamic_data) {
+ dynamic_data = This->dynamic_data;
+ }else {
+ dynamic_data = This->dynamic_data = heap_alloc_zero(sizeof(dispex_dynamic_data_t));
+ if(!dynamic_data)
+ return E_OUTOFMEMORY;
+ }
+
+ if(!dynamic_data->buf_size) {
+ dynamic_data->props = heap_alloc(sizeof(dynamic_prop_t)*4);
+ if(!dynamic_data->props)
+ return E_OUTOFMEMORY;
+ dynamic_data->buf_size = 4;
+ }else if(dynamic_data->buf_size == dynamic_data->prop_cnt) {
+ dynamic_prop_t *new_props;
+
+ new_props = heap_realloc(dynamic_data->props, sizeof(dynamic_prop_t)*(dynamic_data->buf_size<<1));
+ if(!new_props)
+ return E_OUTOFMEMORY;
+
+ dynamic_data->props = new_props;
+ dynamic_data->buf_size <<= 1;
}
- This->dynamic_data->props[This->dynamic_data->prop_cnt].name = heap_strdupW(bstrName);
- VariantInit(&This->dynamic_data->props[This->dynamic_data->prop_cnt].var);
- *pid = DISPID_DYNPROP_0 + This->dynamic_data->prop_cnt++;
+ dynamic_data->props[dynamic_data->prop_cnt].name = heap_strdupW(bstrName);
+ VariantInit(&dynamic_data->props[dynamic_data->prop_cnt].var);
+ *pid = DISPID_DYNPROP_0 + dynamic_data->prop_cnt++;
return S_OK;
}
More information about the wine-cvs
mailing list