Skip to content

Commit c723846

Browse files
committed
Prevent Page access if nil
1 parent 340bb39 commit c723846

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/SCRIPTS/BF/ui.lua

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ local function processMspReply(cmd,rx_buf)
105105
if cmd == nil or rx_buf == nil then
106106
return
107107
end
108+
if Page == nil then
109+
return
110+
end
108111
if cmd == Page.write then
109112
if Page.eepromWrite then
110113
eepromWrite()
@@ -349,10 +352,12 @@ function run_ui(event)
349352
elseif event == EVT_VIRTUAL_NEXT or event == EVT_VIRTUAL_NEXT_REPT then
350353
incLine(1)
351354
elseif event == EVT_VIRTUAL_ENTER then
352-
local field = Page.fields[currentLine]
353-
local idx = field.i or currentLine
354-
if Page.values and Page.values[idx] and (field.ro ~= true) then
355-
currentState = pageStatus.editing
355+
if Page then
356+
local field = Page.fields[currentLine]
357+
local idx = field.i or currentLine
358+
if Page.values and Page.values[idx] and (field.ro ~= true) then
359+
currentState = pageStatus.editing
360+
end
356361
end
357362
elseif event == EVT_VIRTUAL_EXIT then
358363
if isTelemetryScript then

0 commit comments

Comments
 (0)