Ver código fonte

Merge pull request #343 from Dmitry-Me/checkEntityWasPrinted

Ensure proper pattern was found and printed
Lee Thomason 10 anos atrás
pai
commit
4824e95bc0
1 arquivos alterados com 6 adições e 0 exclusões
  1. 6 0
      tinyxml2.cpp

+ 6 - 0
tinyxml2.cpp

@@ -2146,12 +2146,18 @@ void XMLPrinter::PrintString( const char* p, bool restricted )
                         Print( "%.*s", toPrint, p );
                         p += toPrint;
                     }
+                    bool entityPatternPrinted = false;
                     for( int i=0; i<NUM_ENTITIES; ++i ) {
                         if ( entities[i].value == *q ) {
                             Print( "&%s;", entities[i].pattern );
+                            entityPatternPrinted = true;
                             break;
                         }
                     }
+                    if ( !entityPatternPrinted ) {
+                        // TIXMLASSERT( entityPatternPrinted ) causes gcc -Wunused-but-set-variable in release
+                        TIXMLASSERT( false );
+                    }
                     ++p;
                 }
             }