File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,11 @@ void ZigbeeEP::zbReadBasicCluster(const esp_zb_zcl_attribute_t *attribute) {
251251 if (attribute->id == ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID && attribute->data .type == ESP_ZB_ZCL_ATTR_TYPE_CHAR_STRING && attribute->data .value ) {
252252 zbstring_t *zbstr = (zbstring_t *)attribute->data .value ;
253253 char *_read_manufacturer = (char *) malloc (zbstr->len + 1 );
254+ if (_read_manufacturer == nullptr ) {
255+ log_e (" Failed to allocate memory for manufacturer data" );
256+ xSemaphoreGive (lock);
257+ return ;
258+ }
254259 memcpy (_read_manufacturer, zbstr->data , zbstr->len );
255260 _read_manufacturer[zbstr->len ] = ' \0 ' ;
256261 log_i (" Peer Manufacturer is \" %s\" " , _read_manufacturer);
@@ -259,6 +264,11 @@ void ZigbeeEP::zbReadBasicCluster(const esp_zb_zcl_attribute_t *attribute) {
259264 if (attribute->id == ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID && attribute->data .type == ESP_ZB_ZCL_ATTR_TYPE_CHAR_STRING && attribute->data .value ) {
260265 zbstring_t *zbstr = (zbstring_t *)attribute->data .value ;
261266 char *_read_model = (char *) malloc (zbstr->len + 1 );
267+ if (_read_model == nullptr ) {
268+ log_e (" Failed to allocate memory for model data" );
269+ xSemaphoreGive (lock);
270+ return ;
271+ }
262272 memcpy (_read_model, zbstr->data , zbstr->len );
263273 _read_model[zbstr->len ] = ' \0 ' ;
264274 log_i (" Peer Model is \" %s\" " , _read_model);
You can’t perform that action at this time.
0 commit comments