mirror of https://github.com/ARMmbed/mbed-os.git
Add error if allocation of cccd attribute fails
parent
fa2c3633dd
commit
f9af08c0ad
|
@ -23,6 +23,8 @@
|
||||||
#include "wsf_types.h"
|
#include "wsf_types.h"
|
||||||
#include "att_api.h"
|
#include "att_api.h"
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
namespace ble {
|
namespace ble {
|
||||||
namespace impl {
|
namespace impl {
|
||||||
|
|
||||||
|
@ -593,13 +595,18 @@ ble_error_t GattServer::insert_cccd(
|
||||||
*
|
*
|
||||||
* Ownership is passed to the GattCharacteristic
|
* Ownership is passed to the GattCharacteristic
|
||||||
*/
|
*/
|
||||||
GattAttribute* implicit_cccd = new GattAttribute(
|
GattAttribute* implicit_cccd = new (std::nothrow) GattAttribute(
|
||||||
CCCD_UUID,
|
CCCD_UUID,
|
||||||
attribute_it->pValue,
|
attribute_it->pValue,
|
||||||
*attribute_it->pLen,
|
*attribute_it->pLen,
|
||||||
attribute_it->maxLen,
|
attribute_it->maxLen,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
if(implicit_cccd == nullptr) {
|
||||||
|
currentHandle--;
|
||||||
|
return BLE_ERROR_NO_MEM;
|
||||||
|
}
|
||||||
|
|
||||||
implicit_cccd->setHandle(cccds[cccd_cnt].handle);
|
implicit_cccd->setHandle(cccds[cccd_cnt].handle);
|
||||||
implicit_cccd->allowRead(true);
|
implicit_cccd->allowRead(true);
|
||||||
implicit_cccd->allowWrite(true);
|
implicit_cccd->allowWrite(true);
|
||||||
|
|
Loading…
Reference in New Issue