From 14f48d012281f495904566ffd93305623017cbfa Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 18 May 2017 10:40:46 +0200 Subject: [PATCH] Fix mem leak --- include/nfc/nfc-types.h | 2 +- libnfc/chips/pn53x.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nfc/nfc-types.h b/include/nfc/nfc-types.h index a18e4aa..89ad397 100644 --- a/include/nfc/nfc-types.h +++ b/include/nfc/nfc-types.h @@ -311,7 +311,7 @@ typedef enum { NMT_ISO14443B2SR, // ISO14443-2B ST SRx NMT_ISO14443B2CT, // ISO14443-2B ASK CTx NMT_FELICA, - NMT_DEP, + NMT_DEP, // DEP should be kept last one as it's used as end-of-enum } nfc_modulation_type; /** diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 5c19767..0364248 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -85,7 +85,7 @@ pn53x_init(struct nfc_device *pnd) } if (!CHIP_DATA(pnd)->supported_modulation_as_initiator) { - CHIP_DATA(pnd)->supported_modulation_as_initiator = malloc(sizeof(nfc_modulation_type) * 9); + CHIP_DATA(pnd)->supported_modulation_as_initiator = malloc(sizeof(nfc_modulation_type) * (NMT_DEP + 1)); if (! CHIP_DATA(pnd)->supported_modulation_as_initiator) return NFC_ESOFT; int nbSupportedModulation = 0;