]> git.mxchange.org Git - simgear.git/commitdiff
Fix crash when sorting newly-allocated empty vectors
authorandy <andy>
Wed, 2 May 2007 22:24:45 +0000 (22:24 +0000)
committerandy <andy>
Wed, 2 May 2007 22:24:45 +0000 (22:24 +0000)
simgear/nasal/lib.c

index 8763d0ddb93d5c41182210cb1ae3e0785a89754a..0d7265b73e4f67f7ae76be27391a6a58819e7d21 100644 (file)
@@ -514,6 +514,7 @@ static naRef f_sort(naContext c, naRef me, int argc, naRef* args)
     if(argc != 2 || !naIsVector(args[0]) || !naIsFunc(args[1]))
         naRuntimeError(c, "bad/missing argument to sort()");
     sd.subc = naSubContext(c);
+    if(!PTR(args[0]).vec->rec) return naNil();
     sd.elems = PTR(args[0]).vec->rec->array;
     sd.n = PTR(args[0]).vec->rec->size;
     sd.fn = args[1];