Fix parsing bug which causes range(variable) to crash the engine

problem was a segmentation fault caused by trying to access Vector constants[0] which isn't there if op->arguments.size() is not bigger than one.

- the changed OR condition didn't make sense (always true), should be AND
- changes the "constant" variable to be false per default and gets set to true when there is actually something pushed to "constants"
This commit is contained in:
lonesurvivor 2017-02-04 20:51:56 +01:00
parent ad2e1b1b92
commit c71a6c6d71
1 changed files with 3 additions and 4 deletions

View File

@ -2577,7 +2577,7 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
Vector<Node*> args; Vector<Node*> args;
Vector<double> constants; Vector<double> constants;
bool constant=true; bool constant=false;
for(int i=1;i<op->arguments.size();i++) { for(int i=1;i<op->arguments.size();i++) {
args.push_back(op->arguments[i]); args.push_back(op->arguments[i]);
@ -2585,13 +2585,12 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
ConstantNode *c = static_cast<ConstantNode*>(op->arguments[i]); ConstantNode *c = static_cast<ConstantNode*>(op->arguments[i]);
if (c->value.get_type()==Variant::REAL || c->value.get_type()==Variant::INT) { if (c->value.get_type()==Variant::REAL || c->value.get_type()==Variant::INT) {
constants.push_back(c->value); constants.push_back(c->value);
} else { constant=true;
constant=false;
} }
} }
} }
if (args.size()>0 || args.size()<4) { if (args.size()>0 && args.size()<4) {
if (constant) { if (constant) {