Commit fab25802 authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Fixed bugs in handling unterminated nested tables in RTF.

parent 0d8e9e62
...@@ -1461,8 +1461,6 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre ...@@ -1461,8 +1461,6 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
if (!invalidRTF && !inStream.editstream->dwError) if (!invalidRTF && !inStream.editstream->dwError)
{ {
if (format & SF_RTF) { if (format & SF_RTF) {
ME_DisplayItem *para;
/* setup the RTF parser */ /* setup the RTF parser */
memset(&parser, 0, sizeof parser); memset(&parser, 0, sizeof parser);
RTFSetEditStream(&parser, &inStream); RTFSetEditStream(&parser, &inStream);
...@@ -1486,13 +1484,13 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre ...@@ -1486,13 +1484,13 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
RTFRead(&parser); RTFRead(&parser);
RTFFlushOutputBuffer(&parser); RTFFlushOutputBuffer(&parser);
if (!editor->bEmulateVersion10) { /* v4.1 */ if (!editor->bEmulateVersion10) { /* v4.1 */
if (parser.tableDef && parser.tableDef->tableRowStart) if (parser.tableDef && parser.tableDef->tableRowStart &&
(parser.nestingLevel > 0 || parser.canInheritInTbl))
{ {
/* Delete any incomplete table row at the end of the rich text. */ /* Delete any incomplete table row at the end of the rich text. */
int nOfs, nChars; int nOfs, nChars;
ME_DisplayItem *pCell; ME_DisplayItem *pCell;
ME_DisplayItem *para;
para = parser.tableDef->tableRowStart;
parser.rtfMinor = rtfRow; parser.rtfMinor = rtfRow;
/* Complete the table row before deleting it. /* Complete the table row before deleting it.
...@@ -1501,14 +1499,14 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre ...@@ -1501,14 +1499,14 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
* will be added for this change to the current paragraph format. */ * will be added for this change to the current paragraph format. */
if (parser.nestingLevel > 0) if (parser.nestingLevel > 0)
{ {
while (parser.nestingLevel--) while (parser.nestingLevel > 1)
ME_RTFSpecialCharHook(&parser); ME_RTFSpecialCharHook(&parser); /* Decrements nestingLevel */
} else if (parser.canInheritInTbl) { para = parser.tableDef->tableRowStart;
ME_RTFSpecialCharHook(&parser); ME_RTFSpecialCharHook(&parser);
} } else {
if (parser.tableDef && parser.tableDef->tableRowStart && para = parser.tableDef->tableRowStart;
para->member.para.nFlags & MEPF_ROWEND) ME_RTFSpecialCharHook(&parser);
{ assert(para->member.para.nFlags & MEPF_ROWEND);
para = para->member.para.next_para; para = para->member.para.next_para;
} }
pCell = para->member.para.pCell; pCell = para->member.para.pCell;
...@@ -1518,7 +1516,8 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre ...@@ -1518,7 +1516,8 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre
nOfs = ME_GetCursorOfs(editor, 1); nOfs = ME_GetCursorOfs(editor, 1);
nChars = ME_GetCursorOfs(editor, 0) - nOfs; nChars = ME_GetCursorOfs(editor, 0) - nOfs;
ME_InternalDeleteText(editor, nOfs, nChars, TRUE); ME_InternalDeleteText(editor, nOfs, nChars, TRUE);
parser.tableDef->tableRowStart = NULL; if (parser.tableDef)
parser.tableDef->tableRowStart = NULL;
} }
} }
ME_CheckTablesForCorruption(editor); ME_CheckTablesForCorruption(editor);
......
...@@ -242,8 +242,6 @@ void RTFInit(RTF_Info *info) ...@@ -242,8 +242,6 @@ void RTFInit(RTF_Info *info)
info->cpOutputBuffer = heap_alloc(info->dwMaxCPOutputCount); info->cpOutputBuffer = heap_alloc(info->dwMaxCPOutputCount);
} }
if (info->tableDef)
ZeroMemory(info->tableDef, sizeof(info->tableDef));
info->tableDef = NULL; info->tableDef = NULL;
info->nestingLevel = 0; info->nestingLevel = 0;
info->canInheritInTbl = FALSE; info->canInheritInTbl = FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment