Skip to content

Commit

Permalink
- improved time zone name changing check
Browse files Browse the repository at this point in the history
- improved time zone name copying buffer size comparison
  • Loading branch information
fessehaeve committed Apr 5, 2024
1 parent 8ae2293 commit 6501048
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,9 @@ CHIP_ERROR TimeSynchronizationServer::SetTimeZone(const DataModel::DecodableList

if (lastTzState != TimeState::kInvalid)
{
const auto & tzStore = GetTimeZone()[0];
lastTz.offset = tzStore.timeZone.offset;
if (tzStore.timeZone.name.HasValue())
const TimeSyncDataProvider::TimeZoneStore & tzStore = GetTimeZone()[0];
lastTz.offset = tzStore.timeZone.offset;
if (tzStore.timeZone.name.HasValue() && sizeof(name) >= sizeof(tzStore.name))
{
lastTz.name.SetValue(CharSpan(name));
memcpy(name, tzStore.name, sizeof(tzStore.name));
Expand Down Expand Up @@ -623,7 +623,8 @@ CHIP_ERROR TimeSynchronizationServer::SetTimeZone(const DataModel::DecodableList
{
emit = true;
}
if ((tz.name.HasValue() && lastTz.name.HasValue()) && !(tz.name.Value().data_equal(lastTz.name.Value())))
if (tz.name.HasValue() != lastTz.name.HasValue() ||
((tz.name.HasValue() && lastTz.name.HasValue()) && !(tz.name.Value().data_equal(lastTz.name.Value()))))
{
emit = true;
}
Expand Down

0 comments on commit 6501048

Please sign in to comment.