From 6aaf6adfe40e629ead457f2696fa3d8139b59883 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Tue, 29 May 2018 13:10:49 +1000 Subject: src/openssl.c: Factor out xc_dup function --- src/openssl.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/openssl.c b/src/openssl.c index 87e0723..8efe6f7 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -5648,6 +5648,18 @@ EXPORT int luaopen__openssl_x509_extension(lua_State *L) { * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +static void xc_dup(lua_State *L, X509 *x509) { + X509 **ud = prepsimple(L, X509_CERT_CLASS); + + if (!(*ud = X509_dup(x509))) + goto error; + + return; +error: + auxL_error(L, auxL_EOPENSSL, "X509_dup"); +} /* xc_dup() */ + + static int xc_new(lua_State *L) { const char *data; size_t len; @@ -7713,10 +7725,7 @@ static int xl__next(lua_State *L) { lua_pushinteger(L, i); - ret = prepsimple(L, X509_CERT_CLASS); - - if (!(*ret = X509_dup(crt))) - return auxL_error(L, auxL_EOPENSSL, "x509.chain:__next"); + xc_dup(L, crt); break; } -- cgit v1.2.3-59-g8ed1b