From b8182a4d29785dd062858072060b384e522b93f3 Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 14 Aug 2020 09:42:14 +0100 Subject: [PATCH] Fix for sprintf of nil numeric in Nasal Spotted by valgrind, w00t. If you used a numerical formatter, such as f,d or g, with. a nil value, we would read uninitialised data, and generally get confused. --- simgear/nasal/lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simgear/nasal/lib.c b/simgear/nasal/lib.c index d3d2749c..03ae65e0 100644 --- a/simgear/nasal/lib.c +++ b/simgear/nasal/lib.c @@ -472,7 +472,7 @@ static naRef f_sprintf(naContext c, naRef me, int argc, naRef* args) } else { arg = naNumValue(arg); if(naIsNil(arg)) - fout = dosprintf(fstr, "nil"); + fout = dosprintf("nil"); else if(t=='d' || t=='i' || t=='c') fout = dosprintf(fstr, (int)naNumValue(arg).num); else if(t=='o' || t=='u' || t=='x' || t=='X')