From de0ab92cca614caa6af39342896d8a73f8c4b550 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Sun, 20 Mar 2022 15:04:50 +0000 Subject: [PATCH] simgear/nasal/code.c: fixed conversion of strings to bool. We need to check IS_OBJ(r) after IS_STR(r) because all strings are also objects. For example this fixes a bug where an empty string evaluated as true. --- simgear/nasal/code.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simgear/nasal/code.c b/simgear/nasal/code.c index 3dd8de41..00b18f84 100644 --- a/simgear/nasal/code.c +++ b/simgear/nasal/code.c @@ -65,13 +65,13 @@ static int boolify(naContext ctx, naRef r) return naHash_size(r) > 0; } - if (IS_OBJ(r)) return 1; if(IS_STR(r)) { double d; if(naStr_len(r) == 0) return 0; if(naStr_tonum(r, &d)) return d != 0; else return 1; } + if (IS_OBJ(r)) return 1; ERR(ctx, "non-scalar used in boolean context"); return 0; }