Merge pull request #712 from openscad/number-fix

Catch exceptions caused by parsing invalid double values (fixes #706).
memory-leak-fix
Torsten Paul 2014-03-23 00:00:50 +01:00
commit fcf7b27257
1 changed files with 6 additions and 1 deletions

View File

@ -149,7 +149,12 @@ use[ \t\r\n>]*"<" { BEGIN(cond_use); }
{D}+{E}? |
{D}*\.{D}+{E}? |
{D}+\.{D}*{E}? { parserlval.number = boost::lexical_cast<double>(yytext); return TOK_NUMBER; }
{D}+\.{D}*{E}? {
try {
parserlval.number = boost::lexical_cast<double>(yytext);
return TOK_NUMBER;
} catch (boost::bad_lexical_cast) {}
}
"$"?[a-zA-Z0-9_]+ { parserlval.text = strdup(yytext); return TOK_ID; }
\" { BEGIN(cond_string); stringcontents.clear(); }