diff --git a/src/istack.c b/src/istack.c index afa6c73..dc708e4 100644 --- a/src/istack.c +++ b/src/istack.c @@ -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); diff --git a/src/lexer.c b/src/lexer.c index 5d368ac..66ac397 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -144,7 +144,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 && @@ -2307,8 +2307,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))) ) { \*/ diff --git a/version.txt b/version.txt index 915d3ff..43ab206 100644 --- a/version.txt +++ b/version.txt @@ -1,2 +1,2 @@ -5.1.36 -2016.02.01 +5.1.37Test +2016.02.08