From 30b55d966b27a6e14150e6eb74ac07d567b027ce Mon Sep 17 00:00:00 2001 From: "Wilma456 (Jakob0815)" Date: Fri, 11 Aug 2017 15:38:02 +0200 Subject: [PATCH] Add valid check to term.setPaletteColor/getPaletteColor --- .../assets/computercraft/lua/rom/apis/window.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/window.lua b/src/main/resources/assets/computercraft/lua/rom/apis/window.lua index 56ad75cfb..154c44727 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/window.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/window.lua @@ -288,6 +288,10 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) function window.setPaletteColour( colour, r, g, b ) if type( colour ) ~= "number" then error( "bad argument #1 (expected number, got " .. type( colour ) .. ")", 2 ) end + if tHex[colour] == nil then + error( "Invalid color (got " .. colour .. ")" , 2 ) + end + local tCol if type(r) == "number" and g == nil and b == nil then tCol = { colours.rgb8( r ) } @@ -311,6 +315,10 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) window.setPaletteColor = window.setPaletteColour function window.getPaletteColour( colour ) + if type( colour ) ~= "number" then error( "bad argument #1 (expected number, got " .. type( colour ) .. ")", 2 ) end + if tHex[colour] == nil then + error( "Invalid color (got " .. colour .. ")" , 2 ) + end local tCol = tPalette[ colour ] return tCol[1], tCol[2], tCol[3] end