util.encodings: Don't ignore non-strings passed to stringprep functions
authorKim Alvefur <zash@zash.se>
Sat, 02 Nov 2019 13:09:54 +0100
changeset 10375 228338120009
parent 10374 78bda7932f17
child 10376 5482f21a18a2
util.encodings: Don't ignore non-strings passed to stringprep functions If you manage to pass a table or something weird to these, you deserve to know.
util-src/encodings.c
--- a/util-src/encodings.c	Fri Nov 01 23:18:29 2019 +0100
+++ b/util-src/encodings.c	Sat Nov 02 13:09:54 2019 +0100
@@ -283,12 +283,7 @@
 
 	UErrorCode err = U_ZERO_ERROR;
 
-	if(!lua_isstring(L, 1)) {
-		lua_pushnil(L);
-		return 1;
-	}
-
-	input = lua_tolstring(L, 1, &input_len);
+	input = luaL_checklstring(L, 1, &input_len);
 
 	if(input_len >= 1024) {
 		lua_pushnil(L);
@@ -408,11 +403,6 @@
 	int ret;
 	Stringprep_profile_flags flags = 0;
 
-	if(!lua_isstring(L, 1)) {
-		lua_pushnil(L);
-		return 1;
-	}
-
 	s = check_utf8(L, 1, &len);
 
 	/* strict */