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.
This commit is contained in:
James Turner 2020-08-14 09:42:14 +01:00 committed by Automatic Release Builder
parent 27e61b3dec
commit 672afdbc34

View File

@ -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')