diff --git a/src/gfx/pal_packing.cpp b/src/gfx/pal_packing.cpp index 2058476e..ccd47d77 100644 --- a/src/gfx/pal_packing.cpp +++ b/src/gfx/pal_packing.cpp @@ -279,6 +279,8 @@ static void verboseOutputAssignments( // LCOV_EXCL_STOP static void decant(std::vector &assignments, std::vector const &colorSets) { + assume(!assignments.empty()); + // "Decanting" is the process of moving all *things* that can fit in a lower index there auto decantOn = [&assignments](auto const &tryDecanting) { // No need to attempt decanting on palette #0, as there are no palettes to decant to diff --git a/src/gfx/process.cpp b/src/gfx/process.cpp index 02da54c4..ff6c193d 100644 --- a/src/gfx/process.cpp +++ b/src/gfx/process.cpp @@ -377,6 +377,7 @@ static std::pair, std::vector> pal.addColor(color); } } + assume(!palettes.empty()); // "Sort" colors in the generated palettes, see the man page for the flowchart if (options.palSpecType == Options::DMG) { @@ -1150,6 +1151,10 @@ continue_visiting_tiles:; } // LCOV_EXCL_STOP + if (colorSets.empty()) { + fatal("Image does not contain any colors"); + } + if (options.palSpecType == Options::EMBEDDED) { generatePalSpec(image); } diff --git a/test/gfx/no_colors.err b/test/gfx/no_colors.err new file mode 100644 index 00000000..88ae8352 --- /dev/null +++ b/test/gfx/no_colors.err @@ -0,0 +1,2 @@ +FATAL: Image does not contain any colors +Conversion aborted after 1 error diff --git a/test/gfx/no_colors.png b/test/gfx/no_colors.png new file mode 100644 index 00000000..01e89278 Binary files /dev/null and b/test/gfx/no_colors.png differ