From: andy Date: Wed, 2 May 2007 22:24:45 +0000 (+0000) Subject: Fix crash when sorting newly-allocated empty vectors X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=219a7f3a0733ee005610be1afa7bafae31bb7ac5;p=simgear.git Fix crash when sorting newly-allocated empty vectors --- diff --git a/simgear/nasal/lib.c b/simgear/nasal/lib.c index 8763d0dd..0d7265b7 100644 --- a/simgear/nasal/lib.c +++ b/simgear/nasal/lib.c @@ -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];