Fix push_asn1_string().

This commit is contained in:
Bruno Silvestre 2015-11-20 19:16:16 -02:00
parent 6cc8e951d4
commit 172d324243

View File

@ -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) static void push_asn1_string(lua_State* L, ASN1_STRING *string, int encode)
{ {
size_t len; int len;
unsigned char *data; unsigned char *data;
if (!string) if (!string) {
lua_pushnil(L); lua_pushnil(L);
return;
}
switch (encode) { switch (encode) {
case LSEC_AI5_STRING: case LSEC_AI5_STRING:
lua_pushlstring(L, (char*)ASN1_STRING_data(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); lua_pushlstring(L, (char*)data, len);
OPENSSL_free(data); OPENSSL_free(data);
} }
else
lua_pushnil(L);
} }
} }