From 29618b7e27db22a0ee2a30435bc9fa9c3df6466f Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Sat, 5 Mar 2011 21:27:10 +0000 Subject: [PATCH] Fix crash when pn53x_TgInitAsTarget() is aborted. --- libnfc/chips/pn53x.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 823c30a..918c052 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -1416,6 +1416,10 @@ pn53x_TgInitAsTarget (nfc_device_t * pnd, pn53x_target_mode_t ptm, if (!pn53x_transceive (pnd, abtCmd, 36 + szOptionalBytes, abtRx, &szRx)) return false; + if (szRx == 0) { + return false; // transceive was aborted + } + // Note: the first byte is skip: // its the "mode" byte which contains baudrate, DEP and Framing type (Mifare, active or FeliCa) datas. if(pbtModeByte) {