From 172d324243a6b13e3d188700e20850afdeba8add Mon Sep 17 00:00:00 2001 From: Bruno Silvestre Date: Fri, 20 Nov 2015 19:16:16 -0200 Subject: [PATCH] Fix push_asn1_string(). --- src/x509.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/x509.c b/src/x509.c index 5e7a1dd..12c9c2e 100644 --- a/src/x509.c +++ b/src/x509.c @@ -86,10 +86,12 @@ static void push_asn1_objname(lua_State* L, ASN1_OBJECT *object, int no_name) */ static void push_asn1_string(lua_State* L, ASN1_STRING *string, int encode) { - size_t len; + int len; unsigned char *data; - if (!string) + if (!string) { lua_pushnil(L); + return; + } switch (encode) { case LSEC_AI5_STRING: lua_pushlstring(L, (char*)ASN1_STRING_data(string), @@ -101,6 +103,8 @@ static void push_asn1_string(lua_State* L, ASN1_STRING *string, int encode) lua_pushlstring(L, (char*)data, len); OPENSSL_free(data); } + else + lua_pushnil(L); } }