Fixed memory leaks

This commit is contained in:
Frank Morgner 2015-12-09 08:22:24 +01:00
parent 2bb0cb2615
commit 5129c5a060
4 changed files with 7 additions and 2 deletions

View File

@ -1391,6 +1391,7 @@ static CK_RV
pkcs15_release_token(struct sc_pkcs11_card *p11card, void *fw_token) pkcs15_release_token(struct sc_pkcs11_card *p11card, void *fw_token)
{ {
sc_log(context, "pkcs15_release_token() not implemented"); sc_log(context, "pkcs15_release_token() not implemented");
free(fw_token);
return CKR_FUNCTION_REJECTED; return CKR_FUNCTION_REJECTED;
} }

View File

@ -635,7 +635,7 @@ CK_RV C_InitToken(CK_SLOT_ID slotID,
} }
} }
rv = slot->p11card->framework->init_token(slot,slot->fw_data, pPin, ulPinLen, pLabel); rv = slot->p11card->framework->init_token(slot, slot->fw_data, pPin, ulPinLen, pLabel);
if (rv == CKR_OK) { if (rv == CKR_OK) {
/* Now we should re-bind all tokens so they get the /* Now we should re-bind all tokens so they get the
* corresponding function vector and flags */ * corresponding function vector and flags */

View File

@ -107,6 +107,7 @@ void delete_slot(struct sc_pkcs11_slot *slot)
{ {
if (slot) { if (slot) {
list_destroy(&slot->objects); list_destroy(&slot->objects);
list_destroy(&slot->logins);
list_delete(&virtual_slots, slot); list_delete(&virtual_slots, slot);
free(slot); free(slot);
} }
@ -437,8 +438,10 @@ CK_RV slot_token_removed(CK_SLOT_ID id)
/* Release framework stuff */ /* Release framework stuff */
if (slot->p11card != NULL) { if (slot->p11card != NULL) {
if (slot->fw_data != NULL && if (slot->fw_data != NULL &&
slot->p11card->framework != NULL && slot->p11card->framework->release_token != NULL) slot->p11card->framework != NULL && slot->p11card->framework->release_token != NULL) {
slot->p11card->framework->release_token(slot->p11card, slot->fw_data); slot->p11card->framework->release_token(slot->p11card, slot->fw_data);
slot->fw_data = NULL;
}
} }
/* Reset relevant slot properties */ /* Reset relevant slot properties */

View File

@ -974,6 +974,7 @@ static void list_slots(int tokens, int refresh, int print)
rv = p11->C_GetSlotList(tokens, NULL, &p11_num_slots); rv = p11->C_GetSlotList(tokens, NULL, &p11_num_slots);
if (rv != CKR_OK) if (rv != CKR_OK)
p11_fatal("C_GetSlotList(NULL)", rv); p11_fatal("C_GetSlotList(NULL)", rv);
free(p11_slots);
p11_slots = calloc(p11_num_slots, sizeof(CK_SLOT_ID)); p11_slots = calloc(p11_num_slots, sizeof(CK_SLOT_ID));
if (p11_slots == NULL) { if (p11_slots == NULL) {
perror("calloc failed"); perror("calloc failed");