Once MSGRemoveContext is invoked (via SCARDRELEASECONTEXT), cardsList is freed. A repeated invocation of SCARDRELEASECONTEXT (with an empty context handle) results in a use-after-free followed by a double-free.
After MSGRemoveContext, invocation of SCardEstablishContext enable further use-after-free of cardsList in MSGCheckHandleAssociation, MSGRemoveContext, MSGAddHandle, MSGRemoveHandle.
To avoid this problem, destroy the list only when the client connection is terminated. (CVE-2016-10109)