Lua 5.4 change: userdata created with 1 uservalue by default. Set to 0 when possible

This commit is contained in:
dmiller 2024-06-20 20:47:10 +00:00
parent 13be028eb1
commit 136e1c6ed7
8 changed files with 18 additions and 18 deletions

View file

@ -160,13 +160,13 @@ static void obj_to_key(lua_State *L, const ASN1_OBJECT *obj)
nid = OBJ_obj2nid(obj);
if (nid == NID_undef) {
size_t size = 1;
char *buf = (char *) lua_newuserdata(L, size);
char *buf = (char *) lua_newuserdatauv(L, size, 0);
const char *p, *q;
int i, n;
while ((n = OBJ_obj2txt(buf, size, obj, 1)) < 0 || (unsigned) n >= size) {
size = size * 2;
buf = (char *) lua_newuserdata(L, size);
buf = (char *) lua_newuserdatauv(L, size, 0);
memcpy(lua_touserdata(L, -1), lua_touserdata(L, -2), lua_rawlen(L, -2));
lua_replace(L, -2);
}
@ -555,7 +555,7 @@ static int parse_ssl_cert(lua_State *L, X509 *cert)
EVP_PKEY *pubkey;
int pkey_type;
udata = (struct cert_userdata *) lua_newuserdata(L, sizeof(*udata));
udata = (struct cert_userdata *) lua_newuserdatauv(L, sizeof(*udata), 0);
udata->cert = cert;
#define NSE_NUM_CERT_FIELDS 7