fix: check getContactByIdx return value in DM context menu handler

Prevents using uninitialized ContactInfo if the lookup fails.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-13 10:54:36 +02:00
parent eb0f436924
commit 60867a4c9e

View File

@@ -1727,13 +1727,14 @@ public:
if (c == KEY_DOWN && _ctx_sel < 1) { _ctx_sel++; return true; }
if (c == KEY_ENTER && _num_contacts > 0) {
ContactInfo ci;
the_mesh.getContactByIdx(_sorted[_contact_sel], ci);
if (_ctx_sel == 0) {
_task->clearDMUnread(ci.id.pub_key);
} else {
uint8_t nstate = dmNotifState(ci.id.pub_key);
setDmNotifState(ci.id.pub_key, (nstate + 1) % 3);
_ctx_dirty = true;
if (the_mesh.getContactByIdx(_sorted[_contact_sel], ci)) {
if (_ctx_sel == 0) {
_task->clearDMUnread(ci.id.pub_key);
} else {
uint8_t nstate = dmNotifState(ci.id.pub_key);
setDmNotifState(ci.id.pub_key, (nstate + 1) % 3);
_ctx_dirty = true;
}
}
return true;
}