diff --git a/dlls/mshtml/txtrange.c b/dlls/mshtml/txtrange.c
index b8103cef1be..4757215b1b1 100644
--- a/dlls/mshtml/txtrange.c
+++ b/dlls/mshtml/txtrange.c
@@ -535,7 +535,7 @@ HRESULT get_node_text(HTMLDOMNode *node, BSTR *ret)
if (!wstrbuf_init(&buf))
return E_OUTOFMEMORY;
wstrbuf_append_node_rec(&buf, node->nsnode);
- if(buf.buf) {
+ if(buf.buf && *buf.buf) {
*ret = SysAllocString(buf.buf);
if(!*ret)
hres = E_OUTOFMEMORY;