config changes

Fork of nRF51822 by Nordic Semiconductor

Files at this revision

API Documentation at this revision

Comitter:
rgrover1
Date:
Mon Nov 02 09:05:09 2015 +0000
Parent:
449:fd09f590751b
Child:
451:87e7f14a3fa1
Commit message:
Synchronized with git rev 031ae200
Author: Rohit Grover
Merge branch 'patch-1' of https://github.com/Timmmm/ble-nrf51822 into Timmmm-patch-1

Changed in this revision

LICENSE Show annotated file Show diff for this revision Revisions of this file
source/nRF5xGattServer.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/LICENSE	Mon Nov 02 09:05:09 2015 +0000
+++ b/LICENSE	Mon Nov 02 09:05:09 2015 +0000
@@ -1,6 +1,6 @@
 Many of the files in this module have been inherited from the Nordic SDK for
-nRF51822; they come with a BSD-like license offered by Nordic for use with mbed.
-Others come from the mbed SDK, and are licensed under Apache-2.0.
+nRF51822; they come with a BSD-like license offered by Nordic for use in mbed.
+Some other files come from the mbed SDK, and are licensed under Apache-2.0.
 Unless specifically indicated otherwise in a file, files are licensed
 under the Apache 2.0 license, as can be found in: apache-2.0.txt.
 The BSD-like Nordic license can be found in BSD-3clause-Nordic.txt
\ No newline at end of file
--- a/source/nRF5xGattServer.cpp	Mon Nov 02 09:05:09 2015 +0000
+++ b/source/nRF5xGattServer.cpp	Mon Nov 02 09:05:09 2015 +0000
@@ -45,7 +45,6 @@
 /**************************************************************************/
 ble_error_t nRF5xGattServer::addService(GattService &service)
 {
-    /* ToDo: Make sure we don't overflow the array, etc. */
     /* ToDo: Make sure this service UUID doesn't already exist (?) */
     /* ToDo: Basic validation */
 
@@ -63,7 +62,10 @@
 
     /* Add characteristics to the service */
     for (uint8_t i = 0; i < service.getCharacteristicCount(); i++) {
-        GattCharacteristic *p_char = service.getCharacteristic(i);
+		if (characteristicCount >= BLE_TOTAL_CHARACTERISTICS) {
+			return BLE_ERROR_NO_MEM;
+		}
+		GattCharacteristic *p_char = service.getCharacteristic(i);
 
         /* Skip any incompletely defined, read-only characteristics. */
         if ((p_char->getValueAttribute().getValuePtr() == NULL) &&
@@ -108,9 +110,12 @@
         characteristicCount++;
 
         /* Add optional descriptors if any */
-        /* ToDo: Make sure we don't overflow the array */
         for (uint8_t j = 0; j < p_char->getDescriptorCount(); j++) {
-            GattAttribute *p_desc = p_char->getDescriptor(j);
+    		if (descriptorCount >= BLE_TOTAL_DESCRIPTORS) {
+    			return BLE_ERROR_NO_MEM;
+    		}
+
+			GattAttribute *p_desc = p_char->getDescriptor(j);
             /* skip the user-description-descriptor here; this has already been handled when adding the characteristic (above). */
             if (p_desc->getUUID() == BLE_UUID_DESCRIPTOR_CHAR_USER_DESC) {
                 continue;