mshtml: Check for NULL return from allocations.

This commit is contained in:
Marcus Meissner 2009-12-01 23:28:50 +01:00 committed by Alexandre Julliard
parent 8a06bd9e1c
commit 5013c4d96e
1 changed files with 9 additions and 5 deletions

View File

@ -177,12 +177,14 @@ static BOOL is_space_elem(nsIDOMNode *node)
return ret;
}
static inline void wstrbuf_init(wstrbuf_t *buf)
static inline BOOL wstrbuf_init(wstrbuf_t *buf)
{
buf->len = 0;
buf->size = 16;
buf->buf = heap_alloc(buf->size * sizeof(WCHAR));
if (!buf->buf) return FALSE;
*buf->buf = 0;
return TRUE;
}
static inline void wstrbuf_finish(wstrbuf_t *buf)
@ -549,7 +551,8 @@ HRESULT get_node_text(HTMLDOMNode *node, BSTR *ret)
wstrbuf_t buf;
HRESULT hres = S_OK;
wstrbuf_init(&buf);
if (!wstrbuf_init(&buf))
return E_OUTOFMEMORY;
wstrbuf_append_node_rec(&buf, node->nsnode);
if(buf.buf) {
*ret = SysAllocString(buf.buf);
@ -1171,7 +1174,8 @@ static HRESULT WINAPI HTMLTxtRange_get_text(IHTMLTxtRange *iface, BSTR *p)
if(!This->nsrange)
return S_OK;
wstrbuf_init(&buf);
if (!wstrbuf_init(&buf))
return E_OUTOFMEMORY;
range_to_string(This, &buf);
if (buf.buf)
*p = SysAllocString(buf.buf);