diff options
author | daurnimator <quae@daurnimator.com> | 2018-11-01 17:00:38 +1100 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2018-11-01 17:03:01 +1100 |
commit | 3540ec0895993988f32ecb779fe5f56dce0f4753 (patch) | |
tree | 8d4a582d5a51acfd9cd11a6c420cc1a673911374 | |
parent | 0aaec41e02fbf7cb71eb317effdd6d34fe2e5e95 (diff) | |
download | luaossl-3540ec0895993988f32ecb779fe5f56dce0f4753.tar.gz luaossl-3540ec0895993988f32ecb779fe5f56dce0f4753.tar.bz2 luaossl-3540ec0895993988f32ecb779fe5f56dce0f4753.zip |
src/openssl.c: Extend loadfield() to return string length
-rw-r--r-- | src/openssl.c | 6 |
1 files changed, 4 insertions, 2 deletions
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) { |