feat: protect against too big tile maps

This commit is contained in:
2026-11-07 19:37:32 +01:00
parent 3721c192a8
commit 98fec70038
+7 -1
View File
@@ -39,11 +39,17 @@ class Reader:
"Input image is not an 8x8 multiple (%dx%d)", img.width, img.height
)
sys.exit(1)
if img.width * img.height > 256 * 8 * 8:
self.log.error(
"Input image too big, it must have at maximum 256 tiles (currently: %d)",
(img.width * img.height) // (8 * 8),
)
sys.exit(1)
glyphs = []
for y in range(img.height // 8):
for x in range(img.width // 8):
glyphs += [self.__get_img_glyph(img, x, y)]
self.log.info("Loaded glyps from %s", self.source_image_path)
self.log.info("Loaded %d glyphs from %s", len(glyphs), self.source_image_path)
except (OSError, UnidentifiedImageError) as e:
self.log.error(
"Could not read input image at: %s (%s)", self.source_sets_path, e