Fix buffer overflow in dumpNode
The formatted string buffer doesn't need to be used, so we bypass it with string concat
This commit is contained in:
parent
2d0e3b7e0d
commit
a253c53fe7
|
@ -518,8 +518,7 @@ void dumpNode( std::string& buf, TREE_NODE* tok, int depth = 0 )
|
|||
|
||||
if( tok->op & TR_OP_BINARY_MASK )
|
||||
{
|
||||
sprintf( str, "%s", (const char*) formatOpName( tok->op ).c_str() );
|
||||
buf += str;
|
||||
buf += formatOpName( tok->op );
|
||||
dumpNode( buf, tok->leaf[0], depth + 1 );
|
||||
dumpNode( buf, tok->leaf[1], depth + 1 );
|
||||
}
|
||||
|
@ -527,34 +526,30 @@ void dumpNode( std::string& buf, TREE_NODE* tok, int depth = 0 )
|
|||
switch( tok->op )
|
||||
{
|
||||
case TR_NUMBER:
|
||||
sprintf( str, "NUMERIC: " );
|
||||
buf += str;
|
||||
sprintf( str, "%s", formatNode( tok ).c_str() );
|
||||
buf += str;
|
||||
buf += "NUMERIC: ";
|
||||
buf += formatNode( tok );
|
||||
|
||||
if( tok->leaf[0] )
|
||||
dumpNode( buf, tok->leaf[0], depth + 1 );
|
||||
|
||||
break;
|
||||
case TR_STRING:
|
||||
sprintf( str, "STRING: " );
|
||||
buf += str;
|
||||
sprintf( str, "%s", formatNode( tok ).c_str() );
|
||||
buf += str;
|
||||
buf += "STRING: ";
|
||||
buf += formatNode( tok );
|
||||
break;
|
||||
case TR_IDENTIFIER:
|
||||
sprintf( str, "ID: " );
|
||||
buf += str;
|
||||
sprintf( str, "%s", formatNode( tok ).c_str() );
|
||||
buf += str;
|
||||
buf += "ID: ";
|
||||
buf += formatNode( tok );
|
||||
break;
|
||||
case TR_STRUCT_REF:
|
||||
sprintf( str, "SREF: " );
|
||||
buf += str;
|
||||
buf += "SREF: ";
|
||||
dumpNode( buf, tok->leaf[0], depth + 1 );
|
||||
dumpNode( buf, tok->leaf[1], depth + 1 );
|
||||
break;
|
||||
case TR_OP_FUNC_CALL:
|
||||
sprintf( str, "CALL '%s': ", tok->leaf[0]->value.str );
|
||||
buf += str;
|
||||
buf += "CALL '";
|
||||
buf += tok->leaf[0]->value.str;
|
||||
buf += "': ";
|
||||
dumpNode( buf, tok->leaf[1], depth + 1 );
|
||||
break;
|
||||
case TR_UNIT:
|
||||
|
|
Loading…
Reference in New Issue