From e094c8b08b002896c440c3b55785bcf119007c91 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 29 Sep 2009 19:05:32 +0100 Subject: util.encodings: Don't throw an error but return nil when passed nil or a non-string value --- util-src/encodings.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/util-src/encodings.c b/util-src/encodings.c index 65d7d501..bee4365c 100644 --- a/util-src/encodings.c +++ b/util-src/encodings.c @@ -124,8 +124,12 @@ static const luaL_Reg Reg_base64[] = static int stringprep_prep(lua_State *L, const Stringprep_profile *profile) { + if(!lua_isstring(L, 1)) { + lua_pushnil(L); + return 1; + } size_t len; - const char *s = luaL_checklstring(L, 1, &len); + const char *s = lua_tolstring(L, 1, &len); char string[1024]; int ret; if (len >= 1024) { -- cgit v1.2.3