On Wed, Jul 02, 2014 at 05:09:47PM +0800, Jactry Zeng wrote:
- buffer = heap_alloc((nChars + 1) * sizeof(WCHAR));
- if (!buffer)
return E_OUTOFMEMORY;
- ME_GetTextW(This->reOle->editor, buffer, nChars, start, nChars, 0);
- buffer[nChars] = 0;
- /* FIXME: a '\r' should be appended at the end of a story */
- *pbstr = SysAllocString(buffer);
- heap_free(buffer);
There's no need for an intermediate buffer here. Use SysAllocStringLen() to allocate the BSTR and pass it to ME_GetTextW().
Huw.