From 9acc2486787ee83b436b2999cd27f7b1ffb9fd69 Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Tue, 17 Jul 2012 10:32:07 -0700 Subject: phHal4Nfc_ADD: fix memcpy overlap Don't call memcpy when src==dest. It's undefined. When memcpy overlap detection is enabled, this causes the NFC process to crash and burn. Bug: 6826770 Change-Id: I199af98e453953de288964f47248cb59af4deecb --- src/phHal4Nfc_ADD.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/phHal4Nfc_ADD.c b/src/phHal4Nfc_ADD.c index 0a3303c..727b7c4 100644 --- a/src/phHal4Nfc_ADD.c +++ b/src/phHal4Nfc_ADD.c @@ -671,11 +671,14 @@ void phHal4Nfc_TargetDiscoveryComplete( if(phHal_eNfcIP1_Target == Hal4Ctxt->rem_dev_list[Count-1]->RemDevType) { - (void)memcpy( - (void *)Hal4Ctxt->rem_dev_list[0], - (void *)Hal4Ctxt->rem_dev_list[Count-1], - sizeof(phHal_sRemoteDevInformation_t) - ); + if (Count != 1) + { + (void)memcpy( + (void *)Hal4Ctxt->rem_dev_list[0], + (void *)Hal4Ctxt->rem_dev_list[Count-1], + sizeof(phHal_sRemoteDevInformation_t) + ); + } NfcIpDeviceCount = 1; break; } -- cgit v1.1