From: luozheng <1732036298@qq.com> Date: Thu, 16 Jan 2025 03:25:01 +0000 (+0800) Subject: 解决,#1269点击已过时间但未关闭的闹钟,手表卡死过一会死机,出现二次bug X-Git-Tag: v1.3.113-repair_tp~33 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F1632%2F3;p=mirrors%2FFD230.git 解决,#1269点击已过时间但未关闭的闹钟,手表卡死过一会死机,出现二次bug --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmConfigView.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmConfigView.cpp index 33cd189f7..67b372df8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmConfigView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmConfigView.cpp @@ -344,6 +344,16 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep hour > 24 error!"); return; } + // 检查分钟是否在有效范围 + if (min > 59) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep min > 59 error!"); + return; + } + // 检查 week 是否在有效范围 + if (week > 127) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep week out of range!"); + return; + } WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::week = %u!", week); if ((week & 0x7f) == 0x7f) { // 判断0~6位是否都为1,如若都为1,则一周7天闹钟都响应 @@ -398,9 +408,8 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmConfigView::RefreshStep labelTime or labelDay error!"); return; } - showtime[12] = {0}; - sprintf(showtime, "%02d:%02d", hour, min); - // labelTime->SetTime24Hour(hour, min, 0); + memset(showtime, 0, sizeof(showtime)); + snprintf(showtime, sizeof(showtime), "%02d:%02d", hour, min);// 使用更安全的 snprintf 函数 labelTime->SetText(showtime); if (ConfigModel::GetInstance()->GetLanguage() == ZH_CN) labelDay->SetText(weekStr.c_str());