Allow the second (property node) argument to fgcommand() to be nil or
missing, for sanity. Note that this will pass the resulting NULL pointer through into the underlying SGCommand handlers, some of which may be unprepared for it. So basically this is now yet another way you can use Nasal to exercise bugs and hose your sim; no biggie.
This commit is contained in:
parent
b3b87842b1
commit
b693047703
1 changed files with 6 additions and 3 deletions
|
@ -252,10 +252,13 @@ static naRef f_print(naContext c, naRef me, int argc, naRef* args)
|
|||
// an argument.
|
||||
static naRef f_fgcommand(naContext c, naRef me, int argc, naRef* args)
|
||||
{
|
||||
if(argc < 2 || !naIsString(args[0]) || !naIsGhost(args[1]))
|
||||
naRef cmd = argc > 0 ? args[0] : naNil();
|
||||
naRef props = argc > 1 ? args[1] : naNil();
|
||||
if(!naIsString(cmd) || (!naIsNil(props) && !naIsGhost(props)))
|
||||
naRuntimeError(c, "bad arguments to fgcommand()");
|
||||
naRef cmd = args[0], props = args[1];
|
||||
SGPropertyNode_ptr* node = (SGPropertyNode_ptr*)naGhost_ptr(props);
|
||||
SGPropertyNode_ptr* node = NULL;
|
||||
if(!naIsNil(props))
|
||||
node = (SGPropertyNode_ptr*)naGhost_ptr(props);
|
||||
return naNum(globals->get_commands()->execute(naStr_data(cmd), *node));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue