mirror of https://github.com/AxioDL/tinyxml2.git
remove random -1 in length
This commit is contained in:
parent
598c13efa8
commit
a4a36ba3c2
18
tinyxml2.cpp
18
tinyxml2.cpp
|
@ -1005,7 +1005,7 @@ void XMLAttribute::SetAttribute( int v )
|
||||||
void XMLAttribute::SetAttribute( unsigned v )
|
void XMLAttribute::SetAttribute( unsigned v )
|
||||||
{
|
{
|
||||||
char buf[BUF_SIZE];
|
char buf[BUF_SIZE];
|
||||||
TIXML_SNPRINTF( buf, BUF_SIZE-1, "%u", v );
|
TIXML_SNPRINTF( buf, BUF_SIZE, "%u", v );
|
||||||
value.SetStr( buf );
|
value.SetStr( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1013,21 +1013,21 @@ void XMLAttribute::SetAttribute( unsigned v )
|
||||||
void XMLAttribute::SetAttribute( bool v )
|
void XMLAttribute::SetAttribute( bool v )
|
||||||
{
|
{
|
||||||
char buf[BUF_SIZE];
|
char buf[BUF_SIZE];
|
||||||
TIXML_SNPRINTF( buf, BUF_SIZE-1, "%d", v ? 1 : 0 );
|
TIXML_SNPRINTF( buf, BUF_SIZE, "%d", v ? 1 : 0 );
|
||||||
value.SetStr( buf );
|
value.SetStr( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
void XMLAttribute::SetAttribute( double v )
|
void XMLAttribute::SetAttribute( double v )
|
||||||
{
|
{
|
||||||
char buf[BUF_SIZE];
|
char buf[BUF_SIZE];
|
||||||
TIXML_SNPRINTF( buf, BUF_SIZE-1, "%f", v );
|
TIXML_SNPRINTF( buf, BUF_SIZE, "%f", v );
|
||||||
value.SetStr( buf );
|
value.SetStr( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
void XMLAttribute::SetAttribute( float v )
|
void XMLAttribute::SetAttribute( float v )
|
||||||
{
|
{
|
||||||
char buf[BUF_SIZE];
|
char buf[BUF_SIZE];
|
||||||
TIXML_SNPRINTF( buf, BUF_SIZE-1, "%f", v );
|
TIXML_SNPRINTF( buf, BUF_SIZE, "%f", v );
|
||||||
value.SetStr( buf );
|
value.SetStr( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1480,11 +1480,9 @@ void XMLDocument::PrintError() const
|
||||||
|
|
||||||
if ( errorStr1 ) {
|
if ( errorStr1 ) {
|
||||||
TIXML_SNPRINTF( buf1, LEN, "%s", errorStr1 );
|
TIXML_SNPRINTF( buf1, LEN, "%s", errorStr1 );
|
||||||
buf1[LEN-1] = 0;
|
|
||||||
}
|
}
|
||||||
if ( errorStr2 ) {
|
if ( errorStr2 ) {
|
||||||
TIXML_SNPRINTF( buf2, LEN, "%s", errorStr2 );
|
TIXML_SNPRINTF( buf2, LEN, "%s", errorStr2 );
|
||||||
buf2[LEN-1] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf( "XMLDocument error id=%d str1=%s str2=%s\n",
|
printf( "XMLDocument error id=%d str1=%s str2=%s\n",
|
||||||
|
@ -1643,7 +1641,7 @@ void XMLPrinter::PushAttribute( const char* name, const char* value )
|
||||||
void XMLPrinter::PushAttribute( const char* name, int v )
|
void XMLPrinter::PushAttribute( const char* name, int v )
|
||||||
{
|
{
|
||||||
char buf[BUF_SIZE];
|
char buf[BUF_SIZE];
|
||||||
TIXML_SNPRINTF( buf, BUF_SIZE-1, "%d", v );
|
TIXML_SNPRINTF( buf, BUF_SIZE, "%d", v );
|
||||||
PushAttribute( name, buf );
|
PushAttribute( name, buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1651,7 +1649,7 @@ void XMLPrinter::PushAttribute( const char* name, int v )
|
||||||
void XMLPrinter::PushAttribute( const char* name, unsigned v )
|
void XMLPrinter::PushAttribute( const char* name, unsigned v )
|
||||||
{
|
{
|
||||||
char buf[BUF_SIZE];
|
char buf[BUF_SIZE];
|
||||||
TIXML_SNPRINTF( buf, BUF_SIZE-1, "%u", v );
|
TIXML_SNPRINTF( buf, BUF_SIZE, "%u", v );
|
||||||
PushAttribute( name, buf );
|
PushAttribute( name, buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1659,7 +1657,7 @@ void XMLPrinter::PushAttribute( const char* name, unsigned v )
|
||||||
void XMLPrinter::PushAttribute( const char* name, bool v )
|
void XMLPrinter::PushAttribute( const char* name, bool v )
|
||||||
{
|
{
|
||||||
char buf[BUF_SIZE];
|
char buf[BUF_SIZE];
|
||||||
TIXML_SNPRINTF( buf, BUF_SIZE-1, "%d", v ? 1 : 0 );
|
TIXML_SNPRINTF( buf, BUF_SIZE, "%d", v ? 1 : 0 );
|
||||||
PushAttribute( name, buf );
|
PushAttribute( name, buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1667,7 +1665,7 @@ void XMLPrinter::PushAttribute( const char* name, bool v )
|
||||||
void XMLPrinter::PushAttribute( const char* name, double v )
|
void XMLPrinter::PushAttribute( const char* name, double v )
|
||||||
{
|
{
|
||||||
char buf[BUF_SIZE];
|
char buf[BUF_SIZE];
|
||||||
TIXML_SNPRINTF( buf, BUF_SIZE-1, "%f", v );
|
TIXML_SNPRINTF( buf, BUF_SIZE, "%f", v );
|
||||||
PushAttribute( name, buf );
|
PushAttribute( name, buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
xmltest.cpp
22
xmltest.cpp
|
@ -94,12 +94,12 @@ int example_2()
|
||||||
|
|
||||||
int example_3()
|
int example_3()
|
||||||
{
|
{
|
||||||
static const char* xml =
|
static const char* xml =
|
||||||
"<?xml version=\"1.0\"?>"
|
"<?xml version=\"1.0\"?>"
|
||||||
"<!DOCTYPE PLAY SYSTEM \"play.dtd\">"
|
"<!DOCTYPE PLAY SYSTEM \"play.dtd\">"
|
||||||
"<PLAY>"
|
"<PLAY>"
|
||||||
"<TITLE>A Midsummer Night's Dream</TITLE>"
|
"<TITLE>A Midsummer Night's Dream</TITLE>"
|
||||||
"</PLAY>";
|
"</PLAY>";
|
||||||
|
|
||||||
XMLDocument doc;
|
XMLDocument doc;
|
||||||
doc.Parse( xml );
|
doc.Parse( xml );
|
||||||
|
@ -751,6 +751,16 @@ int main( int /*argc*/, const char ** /*argv*/ )
|
||||||
XMLTest( "Clone and Equal", 4, count );
|
XMLTest( "Clone and Equal", 4, count );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// This shouldn't crash.
|
||||||
|
XMLDocument doc;
|
||||||
|
if(XML_NO_ERROR != doc.LoadFile( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
|
||||||
|
{
|
||||||
|
doc.PrintError();
|
||||||
|
}
|
||||||
|
XMLTest( "Error in snprinf handling.", true, doc.Error() );
|
||||||
|
}
|
||||||
|
|
||||||
// ----------- Performance tracking --------------
|
// ----------- Performance tracking --------------
|
||||||
{
|
{
|
||||||
#if defined( _MSC_VER )
|
#if defined( _MSC_VER )
|
||||||
|
|
Loading…
Reference in New Issue