From: Antonio A. <tot...@gm...> - 2016-10-27 22:52:17
|
Hi, there is a memory leak in https://sourceforge.net/p/globalplatform/code/HEAD/tree/trunk/gppcscconnectionplugin/src/gppcscconnectionplugin.c#l221 description: allocating cardInfo->librarySpecific without handling the error case. issue: if SCardConnect fails just go to end leaving cardInfo->librarySpecific allocated fix: suggest to add the green lines regards Antonio cardInfo->librarySpecific = malloc(sizeof(PCSC_CARD_INFO_SPECIFIC)); if (cardInfo->librarySpecific == NULL) { OPGP_ERROR_CREATE_ERROR(status, ENOMEM, OPGP_stringify_error(ENOMEM)); goto end; } pcscCardInfo = GET_PCSC_CARD_INFO_SPECIFIC_P(cardInfo); result = SCardConnect( GET_SCARDCONTEXT(cardContext), readerName, SCARD_SHARE_SHARED, protocol, &(pcscCardInfo->cardHandle), &activeProtocol ); if ( SCARD_S_SUCCESS != result ) { /************** memory leak fix *****************/ * if (cardInfo->librarySpecific != NULL) { free(cardInfo->librarySpecific); cardInfo->librarySpecific = NULL; }* /************** memory leak fix - end ************/ goto end; } |