Skip to content

Commit

Permalink
Fixes invalid JSON in the AAC causing runtimes.
Browse files Browse the repository at this point in the history
  • Loading branch information
PJB3005 committed Sep 20, 2015
1 parent 94c81ca commit d498a94
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions code/modules/atmos_automation/console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,11 @@
if(href_list["read"])
var/code = input("Input exported AAC code.","Automations","") as message|null
if(!code || !Adjacent(usr)) return 0
ReadCode(code)
try // To prevent invalid JSON causing runtimes.
ReadCode(code)
catch
usr << "<span class=warning>Invalid JSON.</span>"
return 1
updateUsrDialog()
investigation_log(I_ATMOS,"had an automations list imported by [key_name(usr)]: [code]")
return 1
Expand Down Expand Up @@ -254,7 +258,7 @@
//writepanic("[__FILE__].[__LINE__] ([src.type])([usr ? usr.ckey : ""]) \\/obj/machinery/computer/general_air_control/atmos_automation/proc/ReadCode() called tick#: [world.time]")
automations.len = 0
var/list/json=json2list(jsonStr)
if(json.len>0)
if(json && json.len > 0)
for(var/list/cData in json)
if(isnull(cData) || !("type" in cData))
testing("AAC: Null cData in root JS array.")
Expand Down

0 comments on commit d498a94

Please sign in to comment.