[scard] fixed memory leak

card_id_and_name_* return allocated values, free after use
This commit is contained in:
Armin Novak 2022-11-30 11:16:09 +01:00 committed by David Fort
parent 58bc1ee4c9
commit e1eacad74c
2 changed files with 10 additions and 5 deletions

View File

@ -140,15 +140,13 @@ static DWORD WINAPI smartcard_context_thread(LPVOID arg)
error = smartcard_complete_irp(smartcard, element->irp, &handled);
if (!handled)
element->irp->Discard(element->irp);
smartcard_operation_free(&element->operation, TRUE);
if (error)
{
smartcard_operation_free(&element->operation, TRUE);
WLog_ERR(TAG, "Queue_Enqueue failed!");
break;
}
smartcard_operation_free(&element->operation, TRUE);
}
}
}

View File

@ -2873,7 +2873,10 @@ static LONG WINAPI PCSC_SCardWriteCacheA(SCARDCONTEXT hContext, UUID* CardIdenti
memcpy(data->data, Data, data->len);
HashTable_Remove(ctx->cache, id);
if (!HashTable_Insert(ctx->cache, id, data))
const BOOL rc = HashTable_Insert(ctx->cache, id, data);
free(id);
if (!rc)
{
pcsc_cache_item_free(data);
return SCARD_E_NO_MEMORY;
@ -2915,11 +2918,15 @@ static LONG WINAPI PCSC_SCardWriteCacheW(SCARDCONTEXT hContext, UUID* CardIdenti
memcpy(data->data, Data, data->len);
HashTable_Remove(ctx->cache, id);
if (!HashTable_Insert(ctx->cache, id, data))
const BOOL rc = HashTable_Insert(ctx->cache, id, data);
free(id);
if (!rc)
{
pcsc_cache_item_free(data);
return SCARD_E_NO_MEMORY;
}
return SCARD_S_SUCCESS;
}