Fix a segfault when auto-calling a "a@{...}" function
Since the called function can return its argument attribute set (e.g. "a"), the latter should not be allocated on the stack. Reported by Shea.
This commit is contained in:
		
							parent
							
								
									f581ce0b0c
								
							
						
					
					
						commit
						88164325fa
					
				
					 1 changed files with 5 additions and 5 deletions
				
			
		|  | @ -790,20 +790,20 @@ void EvalState::autoCallFunction(Bindings & args, Value & fun, Value & res) | |||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     Value actualArgs; | ||||
|     mkAttrs(actualArgs, fun.lambda.fun->formals->formals.size()); | ||||
|     Value * actualArgs = allocValue(); | ||||
|     mkAttrs(*actualArgs, fun.lambda.fun->formals->formals.size()); | ||||
| 
 | ||||
|     foreach (Formals::Formals_::iterator, i, fun.lambda.fun->formals->formals) { | ||||
|         Bindings::iterator j = args.find(i->name); | ||||
|         if (j != args.end()) | ||||
|             actualArgs.attrs->push_back(*j); | ||||
|             actualArgs->attrs->push_back(*j); | ||||
|         else if (!i->def) | ||||
|             throwTypeError("cannot auto-call a function that has an argument without a default value (`%1%')", i->name); | ||||
|     } | ||||
| 
 | ||||
|     actualArgs.attrs->sort(); | ||||
|     actualArgs->attrs->sort(); | ||||
| 
 | ||||
|     callFunction(fun, actualArgs, res); | ||||
|     callFunction(fun, *actualArgs, res); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue