From: Alex Henrie alexhenrie24@gmail.com
--- dlls/mshtml/conpoint.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/conpoint.c b/dlls/mshtml/conpoint.c index baedc8472c1..d927002f682 100644 --- a/dlls/mshtml/conpoint.c +++ b/dlls/mshtml/conpoint.c @@ -216,6 +216,7 @@ static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown * { ConnectionPoint *This = impl_from_IConnectionPoint(iface); IUnknown *sink; + void *new_sinks; DWORD i; HRESULT hres;
@@ -233,10 +234,16 @@ static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown * break; }
- if(i == This->sinks_size) - This->sinks = heap_realloc(This->sinks,(++This->sinks_size)*sizeof(*This->sinks)); + if(i == This->sinks_size) { + new_sinks = heap_realloc(This->sinks, (++This->sinks_size) * sizeof(*This->sinks)); + if(!new_sinks) + goto oom; + This->sinks = new_sinks; + } }else { This->sinks = heap_alloc(sizeof(*This->sinks)); + if(!This->sinks) + goto oom; This->sinks_size = 1; i = 0; } @@ -249,6 +256,10 @@ static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown * This->data->on_advise(This->container->outer, This->data);
return S_OK; + +oom: + IUnknown_Release(sink); + return E_OUTOFMEMORY; }
static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD dwCookie)
Ideally, it would use CRT allocators, which support passing NULL to realloc allowing to simplify the whole logic.
On Wed Nov 23 16:52:28 2022 +0000, Jacek Caban wrote:
Ideally, it would use CRT allocators, which support passing NULL to realloc allowing to simplify the whole logic.
OK, I will convert mshtml to use CRT allocators and then come back to the error handling issue.