diff --git a/src/libopensc/asn1.c b/src/libopensc/asn1.c index d70d0319..b1be88dc 100644 --- a/src/libopensc/asn1.c +++ b/src/libopensc/asn1.c @@ -158,8 +158,10 @@ static void print_hex(const u8 * buf, size_t buflen, size_t depth) char *lines = malloc(lines_len); char *line = lines; - if (buf == NULL || buflen == 0 || lines == NULL) + if (buf == NULL || buflen == 0 || lines == NULL) { + free(lines); return; + } sc_hex_dump(buf, buflen, lines, lines_len); diff --git a/src/libopensc/ctx.c b/src/libopensc/ctx.c index 3dd0c052..e1ca8275 100644 --- a/src/libopensc/ctx.c +++ b/src/libopensc/ctx.c @@ -808,6 +808,7 @@ int sc_context_create(sc_context_t **ctx_out, const sc_context_param_t *parm) set_defaults(ctx, &opts); if (0 != list_init(&ctx->readers)) { + sc_release_context(ctx); return SC_ERROR_OUT_OF_MEMORY; } list_attributes_seeker(&ctx->readers, reader_list_seeker); diff --git a/src/pkcs11/framework-pkcs15.c b/src/pkcs11/framework-pkcs15.c index 5e424969..b7fe8863 100644 --- a/src/pkcs11/framework-pkcs15.c +++ b/src/pkcs11/framework-pkcs15.c @@ -1618,7 +1618,7 @@ pkcs15_login(struct sc_pkcs11_slot *slot, CK_USER_TYPE userType, } } - if (userType == CKU_CONTEXT_SPECIFIC && pin_info) { + if (userType == CKU_CONTEXT_SPECIFIC) { int auth_meth_saved = pin_info->auth_method; sc_log(context, "Setting SC_AC_CONTEXT_SPECIFIC");