diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 3802e10..596db3d 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -969,11 +969,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)
           {
@@ -1101,6 +1101,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 bfc2715..f456a09 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;
 		}
 

