diff --git a/mesecons/util.lua b/mesecons/util.lua index 3cdeb64..234775b 100644 --- a/mesecons/util.lua +++ b/mesecons/util.lua @@ -164,7 +164,9 @@ end function mesecon.get_bit(binary,bit) bit = bit or 1 - local c = binary:len()-(bit-1) + local len = binary:len() + if bit > len then return false end + local c = len-(bit-1) return binary:sub(c,c) == "1" end