util-src/encodings.c
changeset 10363 4ef785f45aa2
parent 10361 72e6d0d7ff9b
child 10375 228338120009
--- a/util-src/encodings.c	Mon Sep 09 22:15:04 2019 +0200
+++ b/util-src/encodings.c	Wed Oct 30 16:22:44 2019 +0100
@@ -296,8 +296,11 @@
 	}
 
 	/* strict */
-	if(lua_toboolean(L, 2)) {
-		flags = 0;
+	if(!lua_isnoneornil(L, 2)) {
+		luaL_checktype(L, 2, LUA_TBOOLEAN);
+		if(lua_toboolean(L, 2)) {
+			flags = 0;
+		}
 	}
 
 	u_strFromUTF8(unprepped, 1024, &unprepped_len, input, input_len, &err);
@@ -413,8 +416,11 @@
 	s = check_utf8(L, 1, &len);
 
 	/* strict */
-	if(lua_toboolean(L, 2)) {
-		flags = STRINGPREP_NO_UNASSIGNED;
+	if(!lua_isnoneornil(L, 2)) {
+		luaL_checktype(L, 2, LUA_TBOOLEAN);
+		if(lua_toboolean(L, 2)) {
+			flags = STRINGPREP_NO_UNASSIGNED;
+		}
 	}
 
 	if(s == NULL || len >= 1024 || len != strlen(s)) {