Skip to content

Commit 3630736

Browse files
authored
fix: OTA buffer overflow caused by slow SetChatMessage (78#1031)
1 parent da228f2 commit 3630736

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

main/application.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,11 @@ void Application::CheckNewVersion(Ota& ota) {
118118
vTaskDelay(pdMS_TO_TICKS(1000));
119119

120120
bool upgrade_success = ota.StartUpgrade([display](int progress, size_t speed) {
121-
char buffer[64];
122-
snprintf(buffer, sizeof(buffer), "%d%% %uKB/s", progress, speed / 1024);
123-
display->SetChatMessage("system", buffer);
121+
std::thread([display, progress, speed]() {
122+
char buffer[32];
123+
snprintf(buffer, sizeof(buffer), "%d%% %uKB/s", progress, speed / 1024);
124+
display->SetChatMessage("system", buffer);
125+
}).detach();
124126
});
125127

126128
if (!upgrade_success) {

0 commit comments

Comments
 (0)