From 57c1b3eda6f48186ad029ed68b8b1920ea1ae2f3 Mon Sep 17 00:00:00 2001 From: Ophestra Umiker Date: Thu, 17 Oct 2024 14:31:13 +0900 Subject: [PATCH] system: handle invalid enablement in String method Invalid enablement is only caused by bad API usage, however panicking on the spot leaves behind messy state that has to be manually cleaned up. Signed-off-by: Ophestra Umiker --- internal/system/enablement.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/system/enablement.go b/internal/system/enablement.go index 7876f6b..f443562 100644 --- a/internal/system/enablement.go +++ b/internal/system/enablement.go @@ -24,6 +24,9 @@ var enablementString = [...]string{ const ELen = len(enablementString) func (e Enablement) String() string { + if int(e) >= ELen { + return "" + } return enablementString[e] }