From 3540ec0895993988f32ecb779fe5f56dce0f4753 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Thu, 1 Nov 2018 17:00:38 +1100 Subject: src/openssl.c: Extend loadfield() to return string length --- src/openssl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/openssl.c b/src/openssl.c index 2495a09..8b73be6 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -801,13 +801,13 @@ static _Bool getfield(lua_State *L, int index, const char *k) { } /* getfield() */ -static _Bool loadfield(lua_State *L, int index, const char *k, int type, void *p) { +static _Bool (loadfield)(lua_State *L, int index, const char *k, int type, void *p, size_t *l) { if (!getfield(L, index, k)) return 0; switch (type) { case LUA_TSTRING: - *(const char **)p = luaL_checkstring(L, -1); + *(const char **)p = luaL_checklstring(L, -1, l); break; case LUA_TNUMBER: *(lua_Number *)p = luaL_checknumber(L, -1); @@ -821,6 +821,8 @@ static _Bool loadfield(lua_State *L, int index, const char *k, int type, void *p return 1; } /* loadfield() */ +#define loadfield_(L, idx, k, type, p, l, ...) loadfield((L), (idx), (k), (type), (p), (l)) +#define loadfield(...) EXPAND( loadfield_(__VA_ARGS__, NULL) ) static void *loadfield_udata(lua_State *L, int index, const char *k, const char *tname) { -- cgit v1.2.3-59-g8ed1b