From 50b19e9f4f213441e9cf9fe4244aef8e8eed2fb8 Mon Sep 17 00:00:00 2001 From: Inversion <40722286+NeoInversion@users.noreply.github.com> Date: Wed, 10 Feb 2021 22:24:31 -0800 Subject: [PATCH] Added argument type check to string.len --- src/cbaselib.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cbaselib.c b/src/cbaselib.c index 8bf93ba..0b6bc01 100644 --- a/src/cbaselib.c +++ b/src/cbaselib.c @@ -516,6 +516,11 @@ int cosmoB_sLen(CState *state, int nargs, CValue *args) { return 0; } + if (!IS_STRING(args[0])) { + cosmoV_typeError(state, "string.len", "", "%s", cosmoV_typeStr(args[0])); + return 0; + } + cosmoV_pushNumber(state, strlen(cosmoV_readCString(args[0]))); return 1;