- Remove another potential sources of infinite loops caused by EOF in

the middle of the font and color tables.
- Closing brace on text level is treated as EOF (effectively
  protecting the control from trash after the end of RTF).
- Removed misleading comment about incomplete buffers (I was
  definitely wrong).
This commit is contained in:
Krzysztof Foltman 2005-10-03 18:45:39 +00:00 committed by Alexandre Julliard
parent 9caef1ba12
commit e098edcdcb
2 changed files with 23 additions and 7 deletions

View File

@ -483,7 +483,12 @@ static void ME_RTFReadHook(RTF_Info *info) {
{ {
ME_Style *s; ME_Style *s;
RTFFlushOutputBuffer(info); RTFFlushOutputBuffer(info);
if (info->stackTop<=1) {
info->rtfClass = rtfEOF;
return;
}
info->stackTop--; info->stackTop--;
assert(info->stackTop >= 0);
if (info->styleChanged) if (info->styleChanged)
{ {
/* FIXME too slow ? how come ? */ /* FIXME too slow ? how come ? */

View File

@ -127,13 +127,6 @@ int _RTFGetChar(RTF_Info *info)
TRACE("\n"); TRACE("\n");
/* Doc says, that if the last buffer wasn't full, it's EOF.
Actually, that's not true. */
/*
if (stream->dwSize > 0 && stream->dwSize == stream->dwUsed
&& stream->dwSize < sizeof(stream->buffer))
return EOF;
*/
if (stream->dwSize <= stream->dwUsed) if (stream->dwSize <= stream->dwUsed)
{ {
ME_StreamInFill(stream); ME_StreamInFill(stream);
@ -455,6 +448,10 @@ int RTFGetToken(RTF_Info *info)
RTFFuncPtr p; RTFFuncPtr p;
TRACE("\n"); TRACE("\n");
/* don't try to return anything once EOF is reached */
if (info->rtfClass == rtfEOF) {
return rtfEOF;
}
for (;;) for (;;)
{ {
@ -885,6 +882,8 @@ static void ReadFontTbl(RTF_Info *info)
for (;;) for (;;)
{ {
RTFGetToken (info); RTFGetToken (info);
if (info->rtfClass == rtfEOF)
break;
if (RTFCheckCM (info, rtfGroup, rtfEndGroup)) if (RTFCheckCM (info, rtfGroup, rtfEndGroup))
break; break;
if (old < 0) /* first entry - determine tbl type */ if (old < 0) /* first entry - determine tbl type */
@ -901,6 +900,8 @@ static void ReadFontTbl(RTF_Info *info)
if (!RTFCheckCM (info, rtfGroup, rtfBeginGroup)) if (!RTFCheckCM (info, rtfGroup, rtfBeginGroup))
RTFPanic (info, "%s: missing \"{\"", fn); RTFPanic (info, "%s: missing \"{\"", fn);
RTFGetToken (info); /* yes, skip to next token */ RTFGetToken (info); /* yes, skip to next token */
if (info->rtfClass == rtfEOF)
break;
} }
fp = New (RTFFont); fp = New (RTFFont);
if (fp == NULL) if (fp == NULL)
@ -1002,12 +1003,18 @@ static void ReadFontTbl(RTF_Info *info)
fn,info->rtfTextBuf); fn,info->rtfTextBuf);
} }
RTFGetToken (info); RTFGetToken (info);
if (info->rtfClass == rtfEOF)
break;
} }
if (info->rtfClass == rtfEOF)
break;
if (old == 0) /* need to see "}" here */ if (old == 0) /* need to see "}" here */
{ {
RTFGetToken (info); RTFGetToken (info);
if (!RTFCheckCM (info, rtfGroup, rtfEndGroup)) if (!RTFCheckCM (info, rtfGroup, rtfEndGroup))
RTFPanic (info, "%s: missing \"}\"", fn); RTFPanic (info, "%s: missing \"}\"", fn);
if (info->rtfClass == rtfEOF)
break;
} }
/* Apply the real properties of the default font */ /* Apply the real properties of the default font */
@ -1055,6 +1062,8 @@ static void ReadColorTbl(RTF_Info *info)
for (;;) for (;;)
{ {
RTFGetToken (info); RTFGetToken (info);
if (info->rtfClass == rtfEOF)
break;
if (RTFCheckCM (info, rtfGroup, rtfEndGroup)) if (RTFCheckCM (info, rtfGroup, rtfEndGroup))
break; break;
cp = New (RTFColor); cp = New (RTFColor);
@ -1074,6 +1083,8 @@ static void ReadColorTbl(RTF_Info *info)
} }
RTFGetToken (info); RTFGetToken (info);
} }
if (info->rtfClass == rtfEOF)
break;
if (!RTFCheckCM (info, rtfText, ';')) if (!RTFCheckCM (info, rtfText, ';'))
RTFPanic (info,"%s: malformed entry", fn); RTFPanic (info,"%s: malformed entry", fn);
} }