diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 60db1bf..c768969 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -970,11 +970,11 @@ static void ME_RTFReadHook(RTF_Info *info) { { ME_Style *s; RTFFlushOutputBuffer(info); - if (info->stackTop<=1) { + info->stackTop--; + if (info->stackTop<=0) { info->rtfClass = rtfEOF; return; } - info->stackTop--; assert(info->stackTop >= 0); if (info->styleChanged) { @@ -1102,6 +1102,9 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre if (parser.lpRichEditOle) IRichEditOle_Release(parser.lpRichEditOle); + if (!inStream.editstream->dwError && parser.stackTop > 0) + inStream.editstream->dwError = HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); + /* Remove last line break, as mandated by tests. This is not affected by CR/LF counters, since RTF streaming presents only \para tokens, which are converted according to the standard rules: \r for 2.0, \r\n for 1.0 diff --git a/dlls/riched20/reader.c b/dlls/riched20/reader.c index 5ee9fa2..760adec 100644 --- a/dlls/riched20/reader.c +++ b/dlls/riched20/reader.c @@ -638,14 +638,16 @@ static void _RTFGetToken2(RTF_Info *info) { int c2; - if ((c = GetChar (info)) != EOF && (c2 = GetChar (info)) != EOF) + if ((c = GetChar (info)) != EOF && (c2 = GetChar (info)) != EOF + && isxdigit(c) && isxdigit(c2)) { - /* should do isxdigit check! */ info->rtfClass = rtfText; info->rtfMajor = RTFCharToHex (c) * 16 + RTFCharToHex (c2); return; } - /* early eof, whoops (class is rtfUnknown) */ + /* early eof, whoops */ + info->rtfClass = rtfEOF; + info->stream->editstream->dwError = -14; return; }