Fix return value going out of scope.
(From Coverity report.)
This commit is contained in:
parent
124afa5fc4
commit
552dde8976
|
@ -108,7 +108,7 @@ std::string UOP::Format() const
|
|||
else if( val->GetType() == VT_NUMERIC )
|
||||
snprintf( str, LIBEVAL_MAX_LITERAL_LENGTH, "PUSH NUM [%.10f]", val->AsDouble() );
|
||||
else
|
||||
snprintf( str, LIBEVAL_MAX_LITERAL_LENGTH, "PUSH STR [%s]", val->AsChars() );
|
||||
snprintf( str, LIBEVAL_MAX_LITERAL_LENGTH, "PUSH STR [%ls]", GetChars( val->AsString() ) );
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -196,11 +196,6 @@ public:
|
|||
return m_valueStr;
|
||||
}
|
||||
|
||||
const char* AsChars() const
|
||||
{
|
||||
return m_valueStr.ToStdString().c_str();
|
||||
}
|
||||
|
||||
bool operator==( const VALUE& b ) const
|
||||
{
|
||||
if( m_type == VT_NUMERIC && b.m_type == VT_NUMERIC )
|
||||
|
|
|
@ -45,9 +45,19 @@ bool testEvalExpr( const std::string expr, LIBEVAL::VALUE expectedResult, bool e
|
|||
}
|
||||
|
||||
if( expectedResult.GetType() == LIBEVAL::VT_NUMERIC )
|
||||
printf("result: %s (got %.10f expected: %.10f)\n", ok ? "OK" : "FAIL", result.AsDouble(), expectedResult.AsDouble() );
|
||||
{
|
||||
printf( "result: %s (got %.10f expected: %.10f)\n",
|
||||
ok ? "OK" : "FAIL",
|
||||
result.AsDouble(),
|
||||
expectedResult.AsDouble() );
|
||||
}
|
||||
else
|
||||
printf("result: %s (got '%s' expected: '%s')\n", ok ? "OK" : "FAIL", result.AsChars(), expectedResult.AsChars() );
|
||||
{
|
||||
printf( "result: %s (got '%ls' expected: '%ls')\n",
|
||||
ok ? "OK" : "FAIL",
|
||||
GetChars( result.AsString() ),
|
||||
GetChars( expectedResult.AsString() ) );
|
||||
}
|
||||
|
||||
if (!ok )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue