Skip to content

Commit 04362e4

Browse files
committed
Fix use of undefined value on failure of sscanf
1 parent 0a0e838 commit 04362e4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

values.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,11 @@ void LLScriptTypecastExpression::determine_value() {
637637
{
638638
double d;
639639
float f = 0.0f;
640-
sscanf( ((LLScriptStringConstant *)value)->get_value(), "%lf", &d );
641-
f = (float)d;
642-
if (mono_mode && (d > -1.1754943157898259e-38 && d < 1.1754943157898259e-38))
643-
f = 0.0f;
640+
if ( sscanf( ((LLScriptStringConstant *)value)->get_value(), "%lf", &d ) == 1 ) {
641+
if ( !mono_mode || (d <= -1.1754943157898259e-38 || d >= 1.1754943157898259e-38) ) {
642+
f = (float)d;
643+
}
644+
}
644645
constant_value = new LLScriptFloatConstant(f);
645646
}
646647
break;

0 commit comments

Comments
 (0)