From 712bc3818d0a49b80e8cc77fedd28b204ea40440 Mon Sep 17 00:00:00 2001 From: Kristian Lauszus Date: Wed, 11 Dec 2013 10:10:12 +0100 Subject: [PATCH] Fixed warning Check if we are at the end of the string properly --- BTD.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BTD.cpp b/BTD.cpp index 83edb198..776774fe 100755 --- a/BTD.cpp +++ b/BTD.cpp @@ -503,9 +503,12 @@ void BTD::HCI_event_task() { break; case EV_REMOTE_NAME_COMPLETE: - if (!hcibuf[2]) { // check if reading is OK - for (uint8_t i = 0; i < min(sizeof (remote_name), sizeof (hcibuf) - 9); i++) + if (!hcibuf[2]) { // Check if reading is OK + for (uint8_t i = 0; i < min(sizeof (remote_name), sizeof (hcibuf) - 9); i++) { remote_name[i] = hcibuf[9 + i]; + if (remote_name[i] == '\0') // End of string + break; + } hci_event_flag |= HCI_FLAG_REMOTE_NAME_COMPLETE; } break; @@ -789,7 +792,7 @@ void BTD::HCI_task() { #ifdef DEBUG_USB_HOST Notify(PSTR("\r\nRemote Name: "), 0x80); for (uint8_t i = 0; i < 30; i++) { - if (remote_name[i] == NULL) + if (remote_name[i] == '\0') // End of string break; Notifyc(remote_name[i], 0x80); }