From 44f1674b096a2e7f775084ec842136cf07e08328 Mon Sep 17 00:00:00 2001 From: Inversion 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;