shithub: rgbds

Download patch

ref: e86eb9337a8e11b029327cef43861ee15e660285
parent: b0f8e04fb7d307700424935181bc7d6530b53d64
author: ISSOtm <[email protected]>
date: Sun Mar 13 07:02:31 EDT 2022

Check the range of the CLI-specified palette size

--- a/src/gfx/main.cpp
+++ b/src/gfx/main.cpp
@@ -350,6 +350,11 @@
 			if (*arg != '\0') {
 				error("Palette size (-s) argument must be a valid number, not \"%s\"", musl_optarg);
 			}
+			if (options.nbColorsPerPal > 4) {
+				error("Palette size (-s) argument must not exceed 4!");
+			} else if (options.nbColorsPerPal == 0) {
+				error("Palette size (-s) argument may not be 0!");
+			}
 			break;
 		case 'T':
 			autoTilemap = true;