Added argument type check to string.len

This commit is contained in:
Inversion 2021-02-10 22:24:31 -08:00 committed by cpunch
parent 472a0ea4c1
commit 50b19e9f4f
1 changed files with 5 additions and 0 deletions

View File

@ -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", "<string>", "%s", cosmoV_typeStr(args[0]));
return 0;
}
cosmoV_pushNumber(state, strlen(cosmoV_readCString(args[0])));
return 1;