Skip to content

Commit be4fc28

Browse files
authored
Prevent Page access if nil (#280)
Prevent Page access if nil
2 parents b1e1c21 + c723846 commit be4fc28

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
@@ -106,6 +106,9 @@ local function processMspReply(cmd,rx_buf)
106106
if cmd == nil or rx_buf == nil then
107107
return
108108
end
109+
if Page == nil then
110+
return
111+
end
109112
if cmd == Page.write then
110113
if Page.eepromWrite then
111114
eepromWrite()
@@ -351,10 +354,12 @@ function run_ui(event)
351354
elseif event == EVT_VIRTUAL_NEXT or event == EVT_VIRTUAL_NEXT_REPT then
352355
incLine(1)
353356
elseif event == EVT_VIRTUAL_ENTER then
354-
local field = Page.fields[currentLine]
355-
local idx = field.i or currentLine
356-
if Page.values and Page.values[idx] and (field.ro ~= true) then
357-
currentState = pageStatus.editing
357+
if Page then
358+
local field = Page.fields[currentLine]
359+
local idx = field.i or currentLine
360+
if Page.values and Page.values[idx] and (field.ro ~= true) then
361+
currentState = pageStatus.editing
362+
end
358363
end
359364
elseif event == EVT_VIRTUAL_EXIT then
360365
if isTelemetryScript then

0 commit comments

Comments
 (0)