]> git.mxchange.org Git - flightgear.git/commitdiff
Fix mean nasal bug when calling setprop("foo")
authorTorsten Dreyer <Torsten@t3r.de>
Mon, 13 Sep 2010 20:15:50 +0000 (22:15 +0200)
committerTorsten Dreyer <Torsten@t3r.de>
Mon, 13 Sep 2010 20:15:50 +0000 (22:15 +0200)
Reported on the forum from Thorsten Renk and analyzed by
Hooray, fixes this issue:
var x="/test/X";
var y="/test/Y";

setprop(x,100); # sets x=100
setprop(y); # sets x=0

setprop(x,100);
setprop(200); # sets x=200

by checking for at least 2 parameters for setprop

src/Scripting/NasalSys.cxx

index 0a221fc6ebe6ae4c357ac853d35b1979fe4460e7..ae5d9c0af73ef1c579050af11c47f53ac552942a 100644 (file)
@@ -212,6 +212,7 @@ static naRef f_setprop(naContext c, naRef me, int argc, naRef* args)
     buf[BUFLEN] = 0;
     char* p = buf;
     int buflen = BUFLEN;
+    if(argc < 2) naRuntimeError(c, "setprop() expects at least 2 arguments");
     for(int i=0; i<argc-1; i++) {
         naRef s = naStringValue(c, args[i]);
         if(naIsNil(s)) return naNil();