Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 031f117

Browse files
authoredMar 28, 2025··
feat(zigbee): use stack memory for name and model
1 parent cb581f3 commit 031f117

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎libraries/Zigbee/src/ZigbeeEP.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,18 @@ void ZigbeeEP::setVersion(uint8_t version) {
3333
}
3434

3535
bool ZigbeeEP::setManufacturerAndModel(const char *name, const char *model) {
36+
constexpr size_t ZB_MAX_NAME_LENGTH = 32;
37+
3638
// Convert manufacturer to ZCL string
3739
size_t name_length = strlen(name);
3840
size_t model_length = strlen(model);
39-
if (name_length > 32 || model_length > 32) {
41+
if (name_length > ZB_MAX_NAME_LENGTH || model_length > ZB_MAX_NAME_LENGTH) {
4042
log_e("Manufacturer or model name is too long");
4143
return false;
4244
}
4345
// Allocate an array of size length + 2 (1 for the length, 1 for null terminator)
44-
char zb_name[name_length + 2];
45-
char zb_model[model_length + 2];
46+
char zb_name[ZB_MAX_NAME_LENGTH + 2];
47+
char zb_model[ZB_MAX_NAME_LENGTH + 2];
4648
// Store the length as the first element
4749
zb_name[0] = static_cast<char>(name_length); // Cast size_t to char
4850
zb_model[0] = static_cast<char>(model_length);

0 commit comments

Comments
 (0)
Please sign in to comment.