From d11e7a1320d0a8537f72e553c997f77e75a9328a Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Wed, 11 Aug 2010 16:38:22 +0000 Subject: [PATCH] Prevent from segfault when nfc_disconnect() on NULL pointer --- libnfc/nfc.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libnfc/nfc.c b/libnfc/nfc.c index ecc0dca..f52ed21 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -234,12 +234,14 @@ nfc_device_t* nfc_connect(nfc_device_desc_t* pndd) */ void nfc_disconnect(nfc_device_t* pnd) { - // Release and deselect all active communications - nfc_initiator_deselect_target(pnd); - // Disable RF field to avoid heating - nfc_configure(pnd,NDO_ACTIVATE_FIELD,false); - // Disconnect, clean up and release the device - pnd->pdc->disconnect(pnd); + if(pnd) { + // Release and deselect all active communications + nfc_initiator_deselect_target(pnd); + // Disable RF field to avoid heating + nfc_configure(pnd,NDO_ACTIVATE_FIELD,false); + // Disconnect, clean up and release the device + pnd->pdc->disconnect(pnd); + } } /**