myeid: fixed resource leak

pkcs15-myeid: fix memory leakage
myeid: fix memory leakage
This commit is contained in:
Viktor Tarasov 2015-05-07 22:04:25 +02:00
parent 475ce71453
commit ac84d282b1
2 changed files with 8 additions and 1 deletions

View File

@ -826,6 +826,8 @@ myeid_convert_ec_signature(struct sc_context *ctx, size_t s_len, unsigned char *
buflen = (s_len + 7)/8*2;
r = sc_asn1_sig_value_sequence_to_rs(ctx, data, datalen, buf, buflen);
if (r < 0)
free(buf);
LOG_TEST_RET(ctx, r, "Failed to cenvert Sig-Value to the raw RS format");
if (buflen > datalen)

View File

@ -70,7 +70,10 @@ myeid_get_init_applet_data(struct sc_profile *profile, struct sc_pkcs15_card *p1
sc_file_dup(&tmp_file, profile->mf_info->file);
if (tmp_file == NULL)
LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot duplicate MF file");
r = sc_pkcs15init_fixup_file(profile, p15card, tmp_file);
if (r < 0)
sc_file_free(tmp_file);
LOG_TEST_RET(ctx, r, "MF fixup failed");
/* AC 'Create DF' and 'Create EF' */
@ -100,6 +103,8 @@ myeid_get_init_applet_data(struct sc_profile *profile, struct sc_pkcs15_card *p1
if (tmp_file == NULL)
LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot duplicate Application DF file");
r = sc_pkcs15init_fixup_file(profile, p15card, tmp_file);
if (r < 0)
sc_file_free(tmp_file);
LOG_TEST_RET(ctx, r, "Application DF fixup failed");
/* AC 'Create DF' and 'Create EF' */
@ -118,8 +123,8 @@ myeid_get_init_applet_data(struct sc_profile *profile, struct sc_pkcs15_card *p1
else if (entry->method == SC_AC_NEVER)
*(data + 6) = 0xFF; /* 'NEVER'. */
*(data + 7) = 0xFF;
sc_file_free(tmp_file);
sc_file_free(tmp_file);
LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
}