Issue #341 - No token can be inserted if istacksize == 0!

This commit is contained in:
Geoff McLane 2016-02-08 15:12:23 +01:00
parent 58229b7e24
commit 03a643f781
2 changed files with 15 additions and 5 deletions

View file

@ -10,6 +10,9 @@
#include "attrs.h"
#include "streamio.h"
#include "tmbstr.h"
#if !defined(NDEBUG) && defined(_MSC_VER)
#include "sprtf.h"
#endif
/* duplicate attributes */
AttVal *TY_(DupAttrs)( TidyDocImpl* doc, AttVal *attrs)
@ -115,6 +118,7 @@ static void PopIStack( TidyDocImpl* doc )
TY_(FreeAttribute)( doc, av );
}
TidyDocFree(doc, istack->element);
istack->element = NULL; /* remove the freed element */
}
static void PopIStackUntil( TidyDocImpl* doc, TidyTagId tid )
@ -267,9 +271,12 @@ Node *TY_(InsertedToken)( TidyDocImpl* doc )
node->end = lexer->txtend; /* was : lexer->txtstart; */
istack = lexer->insert;
#if 0 && defined(_DEBUG)
/* #if 0 && defined(_DEBUG) */
#if !defined(NDEBUG) && defined(_MSC_VER)
if ( lexer->istacksize == 0 )
fprintf( stderr, "0-size istack!\n" );
{
SPRTF( "WARNING: ZERO sized istack!\n" );
}
#endif
node->element = TY_(tmbstrdup)(doc->allocator, istack->element);

View file

@ -101,7 +101,7 @@ static void Show_Node( TidyDocImpl* doc, const char *msg, Node *node )
tmbstr src = lex ? "lexer" : "stream";
SPRTF("R=%d C=%d: ", line, col );
// DEBUG: Be able to set a TRAP on a SPECIFIC row,col
if ((line == 8) && (col == 36)) {
if ((line == 67) && (col == 95)) {
check_me("Show_Node"); // just a debug trap
}
if (lexer && lexer->token &&
@ -2264,8 +2264,11 @@ Node* TY_(GetToken)( TidyDocImpl* doc, GetTokenMode mode )
assert( !(lexer->pushed || lexer->itoken) );
/* at start of block elements, unclosed inline
elements are inserted into the token stream */
if (lexer->insert || lexer->inode) {
elements are inserted into the token stream
Issue #341 - Can NOT insert a token if NO istacksize
*/
if ((lexer->insert || lexer->inode) && lexer->istacksize)
{
/*\ Issue #92: could fix by the following, but instead chose not to stack these 2
* if ( !(lexer->insert && (nodeIsINS(lexer->insert) || nodeIsDEL(lexer->insert))) ) {
\*/